diff options
Diffstat (limited to 'db/migrate')
5 files changed, 34 insertions, 0 deletions
diff --git a/db/migrate/20200215014558_add_hidden_to_statuses.rb b/db/migrate/20200215014558_add_hidden_to_statuses.rb new file mode 100644 index 000000000..886a2f7c4 --- /dev/null +++ b/db/migrate/20200215014558_add_hidden_to_statuses.rb @@ -0,0 +1,5 @@ +class AddHiddenToStatuses < ActiveRecord::Migration[5.2] + def change + add_column :statuses, :hidden, :boolean + end +end diff --git a/db/migrate/20200215020121_add_index_unhidden_to_statuses.rb b/db/migrate/20200215020121_add_index_unhidden_to_statuses.rb new file mode 100644 index 000000000..17f936a00 --- /dev/null +++ b/db/migrate/20200215020121_add_index_unhidden_to_statuses.rb @@ -0,0 +1,7 @@ +class AddIndexUnhiddenToStatuses < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def change + add_index :statuses, [:account_id, :id, :visibility], where: 'NOT hidden', algorithm: :concurrently, name: 'index_statuses_on_account_id_and_id_and_visibility_not_hidden' + end +end diff --git a/db/migrate/20200215021014_set_null_constraint_on_statuses_hidden.rb b/db/migrate/20200215021014_set_null_constraint_on_statuses_hidden.rb new file mode 100644 index 000000000..70b3a764c --- /dev/null +++ b/db/migrate/20200215021014_set_null_constraint_on_statuses_hidden.rb @@ -0,0 +1,7 @@ +class SetNullConstraintOnStatusesHidden < ActiveRecord::Migration[5.2] + def change + safety_assured do + execute 'ALTER TABLE "statuses" ADD CONSTRAINT "statuses_hidden_null" CHECK ("hidden" IS NOT NULL) NOT VALID' + end + end +end diff --git a/db/migrate/20200215021730_set_default_unhidden_on_statuses.rb b/db/migrate/20200215021730_set_default_unhidden_on_statuses.rb new file mode 100644 index 000000000..1d239d110 --- /dev/null +++ b/db/migrate/20200215021730_set_default_unhidden_on_statuses.rb @@ -0,0 +1,8 @@ +class SetDefaultUnhiddenOnStatuses < ActiveRecord::Migration[5.2] + def change + safety_assured do + change_column_default :statuses, :hidden, false + Status.in_batches.update_all(hidden: false) + end + end +end diff --git a/db/migrate/20200215021731_validate_set_default_unhidden_on_statuses.rb b/db/migrate/20200215021731_validate_set_default_unhidden_on_statuses.rb new file mode 100644 index 000000000..b87b61dcc --- /dev/null +++ b/db/migrate/20200215021731_validate_set_default_unhidden_on_statuses.rb @@ -0,0 +1,7 @@ +class ValidateSetDefaultUnhiddenOnStatuses < ActiveRecord::Migration[5.2] + def change + safety_assured do + execute 'ALTER TABLE "statuses" VALIDATE CONSTRAINT "statuses_hidden_null"' + end + end +end |