mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 11:26:21 +00:00
16 lines
487 B
Ruby
16 lines
487 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
# De alguna forma se guardaron objetos duplicados!
|
||
|
class FixDuplicateObjects < ActiveRecord::Migration[6.1]
|
||
|
def up
|
||
|
ActivityPub::Object.group(:uri).count.select { |_, v| v > 1 }.keys.each do |uri|
|
||
|
objects = ActivityPub::Object.where(uri: uri)
|
||
|
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
||
|
|
||
|
ActivityPub.where(object_id: deleted_ids).update_all(object_id: object.first.id, updated_at: Time.now)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def down; end
|
||
|
end
|