Merge pull request #5292 from tgxworld/drop_email_column

Drop unused email column from users table.
This commit is contained in:
Guo Xiang Tan 2017-11-07 10:15:42 +08:00 committed by GitHub
commit 36ba0dfde3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 20 deletions

View File

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

View File

@ -33,28 +33,29 @@ UserOption.where(user_id: -1).update_all(
Group.user_trust_level_change!(-1, TrustLevel[4]) Group.user_trust_level_change!(-1, TrustLevel[4])
# TODO drop email with ignored_columns pattern in rails 5.1
ColumnDropper.drop( ColumnDropper.drop(
table: 'users', table: 'users',
after_migration: 'CreateUserEmails', after_migration: 'DropEmailFromUsers',
columns: %w[ columns: %w[
email_always email
mailing_list_mode email_always
email_digests mailing_list_mode
email_direct email_digests
email_private_messages email_direct
external_links_in_new_tab email_private_messages
enable_quoting external_links_in_new_tab
dynamic_favicon enable_quoting
disable_jump_reply dynamic_favicon
edit_history_public disable_jump_reply
automatically_unpin_topics edit_history_public
digest_after_days automatically_unpin_topics
auto_track_topics_after_msecs digest_after_days
new_topic_duration_minutes auto_track_topics_after_msecs
last_redirected_to_top_at new_topic_duration_minutes
auth_token last_redirected_to_top_at
auth_token_updated_at ], auth_token
auth_token_updated_at
],
on_drop: ->() { on_drop: ->() {
STDERR.puts 'Removing superflous users columns!' 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