-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO3-5386 Remove edit_emails_off and plain_text_skin columns from pref…
…erences table (#4540) * add migration to remove columns from preferences and remove mentions of those columns from preferences.yml * hound
- Loading branch information
Showing
2 changed files
with
53 additions
and
64 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
db/migrate/20230418071728_remove_edit_emails_and_plain_text_skin_from_preferences.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.