Fixed issue #1261 - Adding foreign keys for inconsistent PG tables breaks update.
This commit is contained in:
parent
577c8b7995
commit
5f17ceb48a
1 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,6 @@
|
||||||
class ForeignKeys < ActiveRecord::Migration
|
class ForeignKeys < ActiveRecord::Migration
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def change
|
def change
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
|
@ -217,11 +219,13 @@ class ForeignKeys < ActiveRecord::Migration
|
||||||
]
|
]
|
||||||
|
|
||||||
foreign_keys.each do |foreign_key|
|
foreign_keys.each do |foreign_key|
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Migration.add_foreign_key(*foreign_key)
|
add_foreign_key(*foreign_key)
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.error "Inconsistent data status detected while adding foreign key '#{foreign_key.inspect}': #{e.message}"
|
Rails.logger.error "Inconsistent data status detected while adding foreign key '#{foreign_key.inspect}': #{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue