Fixed issue #1261 - Adding foreign keys for inconsistent PG tables breaks update.

This commit is contained in:
Thorsten Eckel 2017-08-10 11:20:29 +02:00
parent 577c8b7995
commit 5f17ceb48a

View file

@ -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