From 1e56b2f650a2edca29a5a744c24829d1c654df2c Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 9 Mar 2022 22:44:37 +0100 Subject: [PATCH] Fix existing boosts possibly referencing deleted toots (#17730) Follow-up to #17693 --- db/migrate/20220309213005_fix_reblog_deleted_at.rb | 9 +++++++++ db/schema.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20220309213005_fix_reblog_deleted_at.rb diff --git a/db/migrate/20220309213005_fix_reblog_deleted_at.rb b/db/migrate/20220309213005_fix_reblog_deleted_at.rb new file mode 100644 index 0000000000..8ec1813d95 --- /dev/null +++ b/db/migrate/20220309213005_fix_reblog_deleted_at.rb @@ -0,0 +1,9 @@ +class FixReblogDeletedAt < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + def up + safety_assured { execute 'UPDATE statuses s SET deleted_at = r.deleted_at FROM statuses r WHERE s.reblog_of_id = r.id AND r.deleted_at IS NOT NULL' } + end + + def down; end +end diff --git a/db/schema.rb b/db/schema.rb index 6251fa28c5..79e9b0f4dd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_03_07_094650) do +ActiveRecord::Schema.define(version: 2022_03_09_213005) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"