Skip to content

Commit

Permalink
AO3-5386 Remove edit_emails_off and plain_text_skin columns from pref…
Browse files Browse the repository at this point in the history
…erences table (#4540)

* add migration to remove columns from preferences and remove mentions of those columns from preferences.yml

* hound
  • Loading branch information
saltlas authored Dec 3, 2023
1 parent dafb762 commit 927b203
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
class RemoveEditEmailsAndPlainTextSkinFromPreferences < ActiveRecord::Migration[6.1]
def up
if Rails.env.staging? || Rails.env.production?
database = Preference.connection.current_database

puts <<~PTOSC
Schema Change Command:
pt-online-schema-change D=#{database},t=preferences \\
--alter "DROP COLUMN edit_emails_off,
DROP COLUMN plain_text_skin" \\
--no-drop-old-table \\
-uroot --ask-pass --chunk-size=5k --max-flow-ctl 0 --pause-file /tmp/pauseme \\
--max-load Threads_running=15 --critical-load Threads_running=100 \\
--set-vars innodb_lock_wait_timeout=2 --alter-foreign-keys-method=auto \\
--execute
Table Deletion Command:
DROP TABLE IF EXISTS `#{database}`.`_preferences_old`;
PTOSC
else
remove_column :preferences, :edit_emails_off
remove_column :preferences, :plain_text_skin
end
end

def down
if Rails.env.staging? || Rails.env.production?
database = Preference.connection.current_database

puts <<~PTOSC
Schema Change Command:
pt-online-schema-change D=#{database},t=preferences \\
--alter "ADD COLUMN edit_emails_off BOOLEAN NOT NULL DEFAULT 0,
ADD COLUMN plain_text_skin BOOLEAN NOT NULL DEFAULT 0" \\
--no-drop-old-table \\
-uroot --ask-pass --chunk-size=5k --max-flow-ctl 0 --pause-file /tmp/pauseme \\
--max-load Threads_running=15 --critical-load Threads_running=100 \\
--set-vars innodb_lock_wait_timeout=2 --alter-foreign-keys-method=auto \\
--execute
Table Deletion Command:
DROP TABLE IF EXISTS `#{database}`.`_preferences_old`;
PTOSC
else
add_column :preferences, :edit_emails_off, :boolean, default: false, null: false
add_column :preferences, :plain_text_skin, :boolean, default: false, null: false
end
end
end
Loading

0 comments on commit 927b203

Please sign in to comment.