resolve Rails/ReversibleMigrationMethodDefinition errors (#29412)

This commit is contained in:
Kelv 2024-10-25 15:13:06 +08:00 committed by GitHub
parent b15eb28f77
commit a89767913d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 108 additions and 4 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class CreateVestalVersions < ActiveRecord::Migration[4.2] class CreateVestalVersions < ActiveRecord::Migration[4.2]
def self.up def up
create_table :versions do |t| create_table :versions do |t|
t.belongs_to :versioned, polymorphic: true t.belongs_to :versioned, polymorphic: true
t.belongs_to :user, polymorphic: true t.belongs_to :user, polymorphic: true
@ -24,7 +24,7 @@ class CreateVestalVersions < ActiveRecord::Migration[4.2]
end end
end end
def self.down def down
drop_table :versions drop_table :versions
end end
end end

View File

@ -1,11 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
class AddHstoreExtension < ActiveRecord::Migration[4.2] class AddHstoreExtension < ActiveRecord::Migration[4.2]
def self.up def up
execute "CREATE EXTENSION IF NOT EXISTS hstore" execute "CREATE EXTENSION IF NOT EXISTS hstore"
end end
def self.down def down
execute "DROP EXTENSION hstore" execute "DROP EXTENSION hstore"
end end
end end

View File

@ -11,4 +11,8 @@ class RemoveTrustLevels < ActiveRecord::Migration[4.2]
remove_column :users, :moderator remove_column :users, :moderator
add_column :users, :flag_level, :integer, null: false, default: 0 add_column :users, :flag_level, :integer, null: false, default: 0
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -17,6 +17,10 @@ class BackfillPostUploadReverseIndex < ActiveRecord::Migration[4.2]
end end
end end
def down
raise ActiveRecord::IrreversibleMigration
end
def add_to_reverse_index(url, post_id) def add_to_reverse_index(url, post_id)
# make sure we have a url to insert # make sure we have a url to insert
return if url.blank? return if url.blank?

View File

@ -34,4 +34,8 @@ class MigrateWordCounts < ActiveRecord::Migration[4.2]
execute("SELECT id FROM topics WHERE word_count IS NULL LIMIT 500").map { |r| r["id"].to_i } execute("SELECT id FROM topics WHERE word_count IS NULL LIMIT 500").map { |r| r["id"].to_i }
end end
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -15,4 +15,8 @@ class MigrateTosSetting < ActiveRecord::Migration[4.2]
) )
end end
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -8,4 +8,8 @@ class FixTosName < ActiveRecord::Migration[4.2]
WHERE name = 'I have read and accept the <a href="/tos" target="_blank">Terms of Service</a>.' WHERE name = 'I have read and accept the <a href="/tos" target="_blank">Terms of Service</a>.'
SQL SQL
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -9,4 +9,8 @@ WHERE name = 'post_menu'
AND value NOT LIKE '%like-count%' AND value NOT LIKE '%like-count%'
SQL SQL
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -21,4 +21,8 @@ class MigrateOldModeratorPosts < ActiveRecord::Migration[4.2]
migrate_key("pinned_globally.disabled") migrate_key("pinned_globally.disabled")
Rails.application.config.i18n.raise_on_missing_translations = true Rails.application.config.i18n.raise_on_missing_translations = true
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -21,4 +21,8 @@ class MigrateAutoClosePosts < ActiveRecord::Migration[4.2]
SQL SQL
end end
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -5,4 +5,8 @@ class MigrateOldMovedPosts < ActiveRecord::Migration[4.2]
execute "UPDATE posts SET post_type = 3, action_code = 'split_topic' WHERE post_type = 2 AND raw ~* '^I moved [a\\d]+ posts? to a new topic:'" execute "UPDATE posts SET post_type = 3, action_code = 'split_topic' WHERE post_type = 2 AND raw ~* '^I moved [a\\d]+ posts? to a new topic:'"
execute "UPDATE posts SET post_type = 3, action_code = 'split_topic' WHERE post_type = 2 AND raw ~* '^I moved [a\\d]+ posts? to an existing topic:'" execute "UPDATE posts SET post_type = 3, action_code = 'split_topic' WHERE post_type = 2 AND raw ~* '^I moved [a\\d]+ posts? to an existing topic:'"
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -4,4 +4,8 @@ class FixMigratedHosts < ActiveRecord::Migration[4.2]
def up def up
execute "UPDATE embeddable_hosts SET host = regexp_replace(host, '^https?:\/\/', '', 'i')" execute "UPDATE embeddable_hosts SET host = regexp_replace(host, '^https?:\/\/', '', 'i')"
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -7,4 +7,8 @@ class RemoveUserFirsts < ActiveRecord::Migration[4.2]
# continues with other migrations if we can't delete that table # continues with other migrations if we can't delete that table
nil nil
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -4,4 +4,8 @@ class UseHttpsNameChangeInSiteSettings < ActiveRecord::Migration[4.2]
def up def up
execute "UPDATE site_settings SET name = 'force_https' WHERE name = 'use_https'" execute "UPDATE site_settings SET name = 'force_https' WHERE name = 'use_https'"
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -21,4 +21,8 @@ class AddUploadsToCategories < ActiveRecord::Migration[4.2]
WHERE c1.id = c2.id WHERE c1.id = c2.id
SQL SQL
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -9,4 +9,8 @@ class AllowNullIpTopicLinkClick < ActiveRecord::Migration[5.1]
Migration::SafeMigrate.enable! Migration::SafeMigrate.enable!
end end
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -4,4 +4,8 @@ class DropQueuedPosts < ActiveRecord::Migration[5.2]
def up def up
drop_table :queued_posts drop_table :queued_posts
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -8,4 +8,8 @@ class DisableInviteOnlySso < ActiveRecord::Migration[5.2]
AND EXISTS(SELECT 1 FROM site_settings WHERE name = 'enable_sso' AND value = 't') AND EXISTS(SELECT 1 FROM site_settings WHERE name = 'enable_sso' AND value = 't')
SQL SQL
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -8,4 +8,8 @@ class RemoveLikeCountFromPostMenu < ActiveRecord::Migration[5.2]
WHERE name = 'post_menu' WHERE name = 'post_menu'
SQL SQL
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -4,4 +4,8 @@ class DropClaimedById < ActiveRecord::Migration[5.2]
def up def up
remove_column :reviewables, :claimed_by_id remove_column :reviewables, :claimed_by_id
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -23,4 +23,8 @@ class MigratePostEditTimeLimit < ActiveRecord::Migration[5.2]
DO NOTHING DO NOTHING
SQL SQL
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -6,4 +6,8 @@ class AmendOauth2UserInfoIndex < ActiveRecord::Migration[6.0]
execute "DROP INDEX index_oauth2_user_infos_on_user_id_and_provider" execute "DROP INDEX index_oauth2_user_infos_on_user_id_and_provider"
add_index :oauth2_user_infos, %i[user_id provider] add_index :oauth2_user_infos, %i[user_id provider]
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -98,6 +98,10 @@ class MigrateImageUrlToImageUploadId < ActiveRecord::Migration[6.0]
drop_temporary_table! drop_temporary_table!
end end
def down
raise ActiveRecord::IrreversibleMigration
end
def drop_temporary_table! def drop_temporary_table!
Migration::SafeMigrate.disable! Migration::SafeMigrate.disable!
execute <<~SQL execute <<~SQL

View File

@ -3,4 +3,8 @@ class UndoAddProcessedToNotifications < ActiveRecord::Migration[6.0]
def up def up
execute "ALTER TABLE notifications DROP COLUMN IF EXISTS processed" execute "ALTER TABLE notifications DROP COLUMN IF EXISTS processed"
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -6,4 +6,8 @@ class BackfillSvgSprites < ActiveRecord::Migration[7.0]
def up def up
ThemeSvgSprite.refetch! ThemeSvgSprite.refetch!
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -23,4 +23,8 @@ class BackfillAutoBumpCooldownDaysCategorySetting < ActiveRecord::Migration[7.0]
updated_at = NOW(); updated_at = NOW();
SQL SQL
end end
def down
raise ActiveRecord::IrreversibleMigration
end
end end

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class SwapFieldTypeWithFieldTypeEnumOnUserFields < ActiveRecord::Migration[7.0] class SwapFieldTypeWithFieldTypeEnumOnUserFields < ActiveRecord::Migration[7.0]
def change
end
# DROPPED_COLUMNS = { user_fields: %i[field_type] } # DROPPED_COLUMNS = { user_fields: %i[field_type] }
# def up # def up

View File

@ -8,4 +8,7 @@ class DeleteAnonymousUsersFromDirectoryItems < ActiveRecord::Migration[7.1]
WHERE directory_items.user_id = anonymous_users.user_id WHERE directory_items.user_id = anonymous_users.user_id
SQL SQL
end end
def down
end
end end

View File

@ -8,4 +8,7 @@ class ClearDuplicateAdminNotices < ActiveRecord::Migration[7.1]
WHERE subject = #{problem_subject_id} WHERE subject = #{problem_subject_id}
SQL SQL
end end
def down
end
end end