2024-03-18 18:46:03 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# De alguna forma se guardaron objetos duplicados!
|
|
|
|
class FixDuplicateObjects < ActiveRecord::Migration[6.1]
|
|
|
|
def up
|
2024-05-02 19:05:35 +00:00
|
|
|
ActivityPub::Object.group(:uri).count.select { |_, v| v > 1 }.each_key do |uri|
|
2024-03-18 18:46:03 +00:00
|
|
|
objects = ActivityPub::Object.where(uri: uri)
|
|
|
|
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
|
|
|
|
2024-03-18 18:47:38 +00:00
|
|
|
ActivityPub.where(object_id: deleted_ids).update_all(object_id: objects.first.id, updated_at: Time.now)
|
2024-03-18 18:46:03 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down; end
|
|
|
|
end
|