From eaf9bc1a428b338ee666f1da1e32eed7e3b6b25e Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Tue, 30 Jun 2020 17:33:55 -0500 Subject: [Feature] Add in-place post editing --- db/migrate/20200630222227_add_edited_to_statuses.rb | 10 ++++++++++ .../20200630222517_backfill_default_statuses_edited.rb | 14 ++++++++++++++ ...20200702032702_add_conversation_id_index_to_statuses.rb | 7 +++++++ 3 files changed, 31 insertions(+) create mode 100644 db/migrate/20200630222227_add_edited_to_statuses.rb create mode 100644 db/migrate/20200630222517_backfill_default_statuses_edited.rb create mode 100644 db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb (limited to 'db/migrate') diff --git a/db/migrate/20200630222227_add_edited_to_statuses.rb b/db/migrate/20200630222227_add_edited_to_statuses.rb new file mode 100644 index 000000000..c0a5abb97 --- /dev/null +++ b/db/migrate/20200630222227_add_edited_to_statuses.rb @@ -0,0 +1,10 @@ +class AddEditedToStatuses < ActiveRecord::Migration[5.2] + def up + add_column :statuses, :edited, :int + change_column_default :statuses, :edited, 0 + end + + def down + remove_column :statuses, :edited + end +end diff --git a/db/migrate/20200630222517_backfill_default_statuses_edited.rb b/db/migrate/20200630222517_backfill_default_statuses_edited.rb new file mode 100644 index 000000000..cbcbd600b --- /dev/null +++ b/db/migrate/20200630222517_backfill_default_statuses_edited.rb @@ -0,0 +1,14 @@ +class BackfillDefaultStatusesEdited < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + Rails.logger.info('Backfilling "edited" column of table "statuses" to default value 0...') + Status.unscoped.in_batches do |statuses| + statuses.update_all(edited: 0) + end + end + + def down + true + end +end diff --git a/db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb b/db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb new file mode 100644 index 000000000..f35a2fc99 --- /dev/null +++ b/db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb @@ -0,0 +1,7 @@ +class AddConversationIdIndexToStatuses < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def change + safety_assured { add_index :statuses, :conversation_id, where: 'deleted_at IS NULL', algorithm: :concurrently, name: :index_statuses_on_conversation_id } + end +end -- cgit