fix 3
This commit is contained in:
parent
2af5f750ad
commit
3f97292e58
1 changed files with 16 additions and 0 deletions
16
db/migrate/20160220174777_add_status_stat_foreign_key.rb
Normal file
16
db/migrate/20160220174777_add_status_stat_foreign_key.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# db/migrate/[timestamp]_add_status_stat_foreign_key.rb
|
||||||
|
class AddStatusStatForeignKey < ActiveRecord::Migration[8.0]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
add_foreign_key :statuses, :status_stats,
|
||||||
|
validate: false # Important for large tables
|
||||||
|
|
||||||
|
# Validate in background
|
||||||
|
execute("ALTER TABLE statuses VALIDATE CONSTRAINT fk_rails_[constraint_name]")
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_foreign_key :statuses, :status_stats
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue