Drop unused email column from users table.

This commit is contained in:
Guo Xiang Tan 2017-11-07 10:06:42 +08:00
parent 7eb5f78343
commit b3237d37f0
3 changed files with 33 additions and 20 deletions

View File

@ -19,6 +19,9 @@ class User < ActiveRecord::Base
include Roleable
include HasCustomFields
# TODO: Remove this after 7th Jan 2018
self.ignored_columns = %w{email}
has_many :posts
has_many :notifications, dependent: :destroy
has_many :topic_users, dependent: :destroy

View File

@ -33,11 +33,11 @@ UserOption.where(user_id: -1).update_all(
Group.user_trust_level_change!(-1, TrustLevel[4])
# TODO drop email with ignored_columns pattern in rails 5.1
ColumnDropper.drop(
table: 'users',
after_migration: 'CreateUserEmails',
after_migration: 'DropEmailFromUsers',
columns: %w[
email
email_always
mailing_list_mode
email_digests
@ -54,7 +54,8 @@ ColumnDropper.drop(
new_topic_duration_minutes
last_redirected_to_top_at
auth_token
auth_token_updated_at ],
auth_token_updated_at
],
on_drop: ->() {
STDERR.puts 'Removing superflous users columns!'
}

View File

@ -0,0 +1,9 @@
class DropEmailFromUsers < ActiveRecord::Migration[5.1]
def up
# Defer dropping of the columns until the new application code has been deployed.
end
def down
raise ActiveRecord::IrreversibleMigration
end
end