diff --git a/db/migrate/20250120210449_align_transfer_cascade_behavior.rb b/db/migrate/20250120210449_align_transfer_cascade_behavior.rb new file mode 100644 index 00000000000..06b404d3d76 --- /dev/null +++ b/db/migrate/20250120210449_align_transfer_cascade_behavior.rb @@ -0,0 +1,14 @@ +class AlignTransferCascadeBehavior < ActiveRecord::Migration[7.2] + def change + remove_foreign_key :transfers, :account_transactions, column: :inflow_transaction_id + remove_foreign_key :transfers, :account_transactions, column: :outflow_transaction_id + + add_foreign_key :transfers, :account_transactions, + column: :inflow_transaction_id, + on_delete: :cascade + + add_foreign_key :transfers, :account_transactions, + column: :outflow_transaction_id, + on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index dffd8081173..d072986ed37 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2025_01_10_012347) do +ActiveRecord::Schema[7.2].define(version: 2025_01_20_210449) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -696,7 +696,7 @@ add_foreign_key "sessions", "users" add_foreign_key "taggings", "tags" add_foreign_key "tags", "families" - add_foreign_key "transfers", "account_transactions", column: "inflow_transaction_id" - add_foreign_key "transfers", "account_transactions", column: "outflow_transaction_id" + add_foreign_key "transfers", "account_transactions", column: "inflow_transaction_id", on_delete: :cascade + add_foreign_key "transfers", "account_transactions", column: "outflow_transaction_id", on_delete: :cascade add_foreign_key "users", "families" end