diff --git a/app/models/goal.rb b/app/models/goal.rb index dbc96e4df..c020e9982 100644 --- a/app/models/goal.rb +++ b/app/models/goal.rb @@ -5,6 +5,7 @@ class Goal < ApplicationRecord ICONS = Category.icon_codes validates :icon, inclusion: { in: ICONS, allow_nil: true } + validates :color, format: { with: /\A#[0-9A-Fa-f]{6}\z/ }, allow_nil: true belongs_to :family has_many :goal_accounts, dependent: :destroy diff --git a/db/migrate/20260514120001_drop_goal_contributions.rb b/db/migrate/20260514120001_drop_goal_contributions.rb index 7feff22be..ead75eb87 100644 --- a/db/migrate/20260514120001_drop_goal_contributions.rb +++ b/db/migrate/20260514120001_drop_goal_contributions.rb @@ -6,7 +6,7 @@ class DropGoalContributions < ActiveRecord::Migration[7.2] def down create_table :goal_contributions, id: :uuid do |t| t.references :goal, null: false, foreign_key: { on_delete: :cascade }, type: :uuid - t.references :account, null: false, foreign_key: { on_delete: :restrict }, type: :uuid + t.references :account, null: false, foreign_key: { on_delete: :cascade }, type: :uuid t.decimal :amount, precision: 19, scale: 4, null: false t.string :currency, null: false t.string :source, default: "manual", null: false