Folllow up for issue #1977 - recent_views fk already exists.

This commit is contained in:
Martin Edenhofer 2018-05-08 13:29:43 +02:00
parent cf88f53095
commit 156abbbcf9

View file

@ -15,15 +15,12 @@ class Issue1977RemoveInvalidUserForeignKeys < ActiveRecord::Migration[5.1]
Avatar.joins('LEFT OUTER JOIN users ON avatars.o_id = users.id')
.where('users.id IS NULL')
.where(
object_lookup_id: ObjectLookup.by_name('User')
)
.where(object_lookup_id: ObjectLookup.by_name('User'))
.destroy_all
# add (possibly) missing foreign_key
foreign_keys = [
%i[online_notifications users],
[:recent_views, :users, column: :created_by_id]
]
foreign_keys.each do |args|