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: Check that setting does not exist before migrate #203

Merged
merged 1 commit into from
Aug 7, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,59 @@

class RenameIncorrectTopicVotingSiteSettings < ActiveRecord::Migration[7.0]
def up
execute "UPDATE site_settings SET name = 'topic_voting_alert_votes_left' WHERE name = 'voting_alert_votes_left'"
execute "UPDATE site_settings SET name = 'topic_voting_enabled' WHERE name = 'voting_enabled'"
execute "UPDATE site_settings SET name = 'topic_voting_show_who_voted' WHERE name = 'voting_show_who_voted'"
execute "UPDATE site_settings SET name = 'topic_voting_show_votes_on_profile' WHERE name = 'voting_show_votes_on_profile'"
execute "UPDATE site_settings SET name = 'topic_voting_tl0_vote_limit' WHERE name = 'voting_tl0_vote_limit'"
execute "UPDATE site_settings SET name = 'topic_voting_tl1_vote_limit' WHERE name = 'voting_tl1_vote_limit'"
execute "UPDATE site_settings SET name = 'topic_voting_tl2_vote_limit' WHERE name = 'voting_tl2_vote_limit'"
execute "UPDATE site_settings SET name = 'topic_voting_tl3_vote_limit' WHERE name = 'voting_tl3_vote_limit'"
execute "UPDATE site_settings SET name = 'topic_voting_tl4_vote_limit' WHERE name = 'voting_tl4_vote_limit'"
execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_alert_votes_left'
WHERE name = 'voting_alert_votes_left' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_alert_votes_left');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_enabled'
WHERE name = 'voting_enabled' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_enabled');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_show_who_voted'
WHERE name = 'voting_show_who_voted' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_show_who_voted');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_show_votes_on_profile'
WHERE name = 'voting_show_votes_on_profile' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_show_votes_on_profile');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_tl0_vote_limit'
WHERE name = 'voting_tl0_vote_limit' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_tl0_vote_limit');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_tl1_vote_limit'
WHERE name = 'voting_tl1_vote_limit' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_tl1_vote_limit');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_tl2_vote_limit'
WHERE name = 'voting_tl2_vote_limit' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_tl2_vote_limit');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_tl3_vote_limit'
WHERE name = 'voting_tl3_vote_limit' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_tl3_vote_limit');
SQL

execute <<-SQL
UPDATE site_settings SET name = 'topic_voting_tl4_vote_limit'
WHERE name = 'voting_tl4_vote_limit' AND
NOT EXISTS (SELECT 1 FROM site_settings WHERE name = 'topic_voting_tl4_vote_limit');
SQL
end

def down
Expand Down