Cleanup migration that removes duplicating AspectVisibilities

This commit is contained in:
cmrd Senya 2016-05-31 20:48:07 +03:00
parent 717554edac
commit fd975eeae5
No known key found for this signature in database
GPG key ID: 5FCC5BA680E67BFE
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,11 @@
class RemoveDuplicateAspectVisibilities < ActiveRecord::Migration
def up
where = "WHERE a1.aspect_id = a2.aspect_id AND a1.shareable_id = a2.shareable_id AND "\
"a1.shareable_type = a2.shareable_type AND a1.id > a2.id"
if AppConfig.postgres?
execute("DELETE FROM aspect_visibilities AS a1 USING aspect_visibilities AS a2 #{where}")
else
execute("DELETE a1 FROM aspect_visibilities a1, aspect_visibilities a2 #{where}")
end
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160327103605) do
ActiveRecord::Schema.define(version: 20160531170531) do
create_table "account_deletions", force: :cascade do |t|
t.string "diaspora_handle", limit: 255