diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-06-30 09:43:18 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-06-30 09:43:18 +0200 |
commit | 81d8a20a8895406ca62e43376485c70df4f343c3 (patch) | |
tree | 3b89fc96b9bb005a45955dc057e9a78f00051dd0 /db | |
parent | a4c828f8e73672ee344ab234ef11b173d44e1fdb (diff) | |
parent | 653c925beb800b07a493e6915c784ddf936eecc3 (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20210416200740_create_canonical_email_blocks.rb | 2 | ||||
-rw-r--r-- | db/migrate/20210630000137_fix_canonical_email_blocks_foreign_key.rb | 13 | ||||
-rw-r--r-- | db/schema.rb | 4 |
3 files changed, 16 insertions, 3 deletions
diff --git a/db/migrate/20210416200740_create_canonical_email_blocks.rb b/db/migrate/20210416200740_create_canonical_email_blocks.rb index a1f1660bf..32c44646c 100644 --- a/db/migrate/20210416200740_create_canonical_email_blocks.rb +++ b/db/migrate/20210416200740_create_canonical_email_blocks.rb @@ -2,7 +2,7 @@ class CreateCanonicalEmailBlocks < ActiveRecord::Migration[6.1] def change create_table :canonical_email_blocks do |t| t.string :canonical_email_hash, null: false, default: '', index: { unique: true } - t.belongs_to :reference_account, null: false, foreign_key: { on_cascade: :delete, to_table: 'accounts' } + t.belongs_to :reference_account, null: false, foreign_key: { to_table: 'accounts' } t.timestamps end diff --git a/db/migrate/20210630000137_fix_canonical_email_blocks_foreign_key.rb b/db/migrate/20210630000137_fix_canonical_email_blocks_foreign_key.rb new file mode 100644 index 000000000..64cf84448 --- /dev/null +++ b/db/migrate/20210630000137_fix_canonical_email_blocks_foreign_key.rb @@ -0,0 +1,13 @@ +class FixCanonicalEmailBlocksForeignKey < ActiveRecord::Migration[6.1] + def up + safety_assured do + execute 'ALTER TABLE canonical_email_blocks DROP CONSTRAINT fk_rails_1ecb262096, ADD CONSTRAINT fk_rails_1ecb262096 FOREIGN KEY (reference_account_id) REFERENCES accounts(id) ON DELETE CASCADE;' + end + end + + def down + safety_assured do + execute 'ALTER TABLE canonical_email_blocks DROP CONSTRAINT fk_rails_1ecb262096, ADD CONSTRAINT fk_rails_1ecb262096 FOREIGN KEY (reference_account_id) REFERENCES accounts(id);' + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1cc3957b1..6d848d5bd 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.define(version: 2021_06_09_202149) do +ActiveRecord::Schema.define(version: 2021_06_30_000137) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -999,7 +999,7 @@ ActiveRecord::Schema.define(version: 2021_06_09_202149) do add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade add_foreign_key "bookmarks", "accounts", on_delete: :cascade add_foreign_key "bookmarks", "statuses", on_delete: :cascade - add_foreign_key "canonical_email_blocks", "accounts", column: "reference_account_id" + add_foreign_key "canonical_email_blocks", "accounts", column: "reference_account_id", on_delete: :cascade add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade add_foreign_key "custom_filters", "accounts", on_delete: :cascade |