DEV: Also rename sequences away from discourse_voting prefix (#224)

This commit is contained in:
Natalie Tay 2024-12-10 19:13:23 +08:00 committed by GitHub
parent 434749dbdc
commit ad09407f31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
class RenameSequences < ActiveRecord::Migration[7.0]
def up
rename_sequence(
"discourse_voting_topic_vote_count_id_seq",
"topic_voting_topic_vote_count_id_seq",
)
rename_sequence("discourse_voting_votes_id_seq", "topic_voting_votes_id_seq")
rename_sequence(
"discourse_voting_category_settings_id_seq",
"topic_voting_category_settings_id_seq",
)
end
def down
raise ActiveRecord::IrreversibleMigration
end
private
def rename_sequence(existing_sequence_name, new_name)
execute <<~SQL
ALTER SEQUENCE #{existing_sequence_name}
RENAME TO #{new_name};
SQL
end
end