Skip to content

Commit

Permalink
DEV: Also rename sequences away from discourse_voting prefix (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
nattsw authored Dec 10, 2024
1 parent 434749d commit ad09407
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions db/migrate/20241210081242_rename_sequences.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ad09407

Please sign in to comment.