From 528a7f57fa8a31d1a901c247cc55b214e2dc1af5 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 26 Jun 2024 09:51:11 -0400 Subject: [PATCH] Fix `Rails/ReversibleMigration` cop for `change_column` (#30835) --- db/migrate/20160223164502_make_uris_nullable_in_statuses.rb | 6 +++++- ...170322143850_change_primary_key_to_bigint_on_statuses.rb | 6 +++++- .../20170609145826_remove_default_language_from_statuses.rb | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/db/migrate/20160223164502_make_uris_nullable_in_statuses.rb b/db/migrate/20160223164502_make_uris_nullable_in_statuses.rb index fff07093c..ebb572bd6 100644 --- a/db/migrate/20160223164502_make_uris_nullable_in_statuses.rb +++ b/db/migrate/20160223164502_make_uris_nullable_in_statuses.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true class MakeUrisNullableInStatuses < ActiveRecord::Migration[4.2] - def change + def up change_column :statuses, :uri, :string, null: true, default: nil end + + def down + raise ActiveRecord::IrreversibleMigration + end end diff --git a/db/migrate/20170322143850_change_primary_key_to_bigint_on_statuses.rb b/db/migrate/20170322143850_change_primary_key_to_bigint_on_statuses.rb index b98fffab8..e7fcb75a4 100644 --- a/db/migrate/20170322143850_change_primary_key_to_bigint_on_statuses.rb +++ b/db/migrate/20170322143850_change_primary_key_to_bigint_on_statuses.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class ChangePrimaryKeyToBigintOnStatuses < ActiveRecord::Migration[5.0] - def change + def up change_table(:statuses, bulk: true) do |t| t.change :id, :bigint t.change :reblog_of_id, :bigint @@ -16,4 +16,8 @@ class ChangePrimaryKeyToBigintOnStatuses < ActiveRecord::Migration[5.0] change_column :statuses_tags, :status_id, :bigint change_column :stream_entries, :activity_id, :bigint end + + def down + raise ActiveRecord::IrreversibleMigration + end end diff --git a/db/migrate/20170609145826_remove_default_language_from_statuses.rb b/db/migrate/20170609145826_remove_default_language_from_statuses.rb index 28b4172a8..122c32228 100644 --- a/db/migrate/20170609145826_remove_default_language_from_statuses.rb +++ b/db/migrate/20170609145826_remove_default_language_from_statuses.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true class RemoveDefaultLanguageFromStatuses < ActiveRecord::Migration[5.1] - def change + def up change_column :statuses, :language, :string, default: nil, null: true end + + def down + raise ActiveRecord::IrreversibleMigration + end end