diff --git a/app/models/user.rb b/app/models/user.rb index 522081371f2..881d162ec45 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/db/fixtures/009_users.rb b/db/fixtures/009_users.rb index 23d024fe19f..f1bee9cd16e 100644 --- a/db/fixtures/009_users.rb +++ b/db/fixtures/009_users.rb @@ -33,28 +33,29 @@ 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', - columns: %w[ - email_always - mailing_list_mode - email_digests - email_direct - email_private_messages - external_links_in_new_tab - enable_quoting - dynamic_favicon - disable_jump_reply - edit_history_public - automatically_unpin_topics - digest_after_days - auto_track_topics_after_msecs - new_topic_duration_minutes - last_redirected_to_top_at - auth_token - auth_token_updated_at ], + after_migration: 'DropEmailFromUsers', + columns: %w[ + email + email_always + mailing_list_mode + email_digests + email_direct + email_private_messages + external_links_in_new_tab + enable_quoting + dynamic_favicon + disable_jump_reply + edit_history_public + automatically_unpin_topics + digest_after_days + auto_track_topics_after_msecs + new_topic_duration_minutes + last_redirected_to_top_at + auth_token + auth_token_updated_at + ], on_drop: ->() { STDERR.puts 'Removing superflous users columns!' } diff --git a/db/migrate/20171107020512_drop_email_from_users.rb b/db/migrate/20171107020512_drop_email_from_users.rb new file mode 100644 index 00000000000..f5697d37187 --- /dev/null +++ b/db/migrate/20171107020512_drop_email_from_users.rb @@ -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