Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Drop old tables that have been renamed #221

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions db/migrate/20241203125415_rename_reassign_sequences.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

class RenameReassignSequences < ActiveRecord::Migration[7.0]
def up
reassign_sequence("discourse_voting_topic_vote_count_id_seq", "topic_voting_topic_vote_count")
reassign_sequence("discourse_voting_votes_id_seq", "topic_voting_votes")
reassign_sequence("discourse_voting_category_settings_id_seq", "topic_voting_category_settings")
end

def down
raise ActiveRecord::IrreversibleMigration
end

private

def reassign_sequence(sequence_name, new_table_name)
execute <<~SQL
ALTER SEQUENCE #{sequence_name}
OWNED BY #{new_table_name}.id;
SQL
end
end
13 changes: 13 additions & 0 deletions db/post_migrate/20241203125523_drop_old_discourse_voting_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class DropOldDiscourseVotingTables < ActiveRecord::Migration[7.0]
def up
drop_table :discourse_voting_topic_vote_count, if_exists: true
drop_table :discourse_voting_votes, if_exists: true
drop_table :discourse_voting_category_settings, if_exists: true
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
Loading