discourse/db/migrate/20160615024524_rename_digest_unsbscribe_keys.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

22 lines
682 B
Ruby

# frozen_string_literal: true
class RenameDigestUnsbscribeKeys < ActiveRecord::Migration[4.2]
def up
rename_table :digest_unsubscribe_keys, :unsubscribe_keys
add_column :unsubscribe_keys, :unsubscribe_key_type, :string
add_column :unsubscribe_keys, :topic_id, :int
add_column :unsubscribe_keys, :post_id, :int
execute "UPDATE unsubscribe_keys SET unsubscribe_key_type = 'digest' WHERE unsubscribe_key_type IS NULL"
end
def down
remove_column :unsubscribe_keys, :unsubscribe_key_type
remove_column :unsubscribe_keys, :topic_id
remove_column :unsubscribe_keys, :post_id
rename_table :unsubscribe_keys, :digest_unsubscribe_keys
end
end