DEV: Also rename sequences away from discourse_voting prefix

This commit is contained in:
Nat 2024-12-10 18:22:31 +08:00
parent 434749dbdc
commit db731fa749
No known key found for this signature in database
GPG Key ID: 4938B35D927EC773
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