mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Remove email column from user table
This commit is contained in:
parent
b3fd091379
commit
c705159d22
@ -1123,7 +1123,6 @@ end
|
|||||||
# name :string
|
# name :string
|
||||||
# seen_notification_id :integer default(0), not null
|
# seen_notification_id :integer default(0), not null
|
||||||
# last_posted_at :datetime
|
# last_posted_at :datetime
|
||||||
# email :string(513)
|
|
||||||
# password_hash :string(64)
|
# password_hash :string(64)
|
||||||
# salt :string(32)
|
# salt :string(32)
|
||||||
# active :boolean default(FALSE), not null
|
# active :boolean default(FALSE), not null
|
||||||
|
@ -35,8 +35,9 @@ Group.user_trust_level_change!(-1, TrustLevel[4])
|
|||||||
|
|
||||||
ColumnDropper.drop(
|
ColumnDropper.drop(
|
||||||
table: 'users',
|
table: 'users',
|
||||||
after_migration: 'AddUserAuthTokens',
|
after_migration: 'CreateUserEmails',
|
||||||
columns: %w[
|
columns: %w[
|
||||||
|
email
|
||||||
email_always
|
email_always
|
||||||
mailing_list_mode
|
mailing_list_mode
|
||||||
email_digests
|
email_digests
|
||||||
|
@ -30,13 +30,13 @@ class ColumnDropper
|
|||||||
on_drop&.call
|
on_drop&.call
|
||||||
|
|
||||||
columns.each do |column|
|
columns.each do |column|
|
||||||
|
ActiveRecord::Base.exec_sql <<~SQL
|
||||||
|
DROP TRIGGER IF EXISTS #{readonly_trigger_name(table, column)} ON #{table};
|
||||||
|
DROP FUNCTION IF EXISTS #{readonly_function_name(table, column)};
|
||||||
|
SQL
|
||||||
|
|
||||||
# safe cause it is protected on method entry, can not be passed in params
|
# safe cause it is protected on method entry, can not be passed in params
|
||||||
ActiveRecord::Base.exec_sql("ALTER TABLE #{table} DROP COLUMN IF EXISTS #{column}")
|
ActiveRecord::Base.exec_sql("ALTER TABLE #{table} DROP COLUMN IF EXISTS #{column}")
|
||||||
|
|
||||||
ActiveRecord::Base.exec_sql <<~SQL
|
|
||||||
DROP FUNCTION IF EXISTS #{readonly_function_name(table, column)};
|
|
||||||
DROP TRIGGER IF EXISTS #{readonly_trigger_name(table, column)} ON #{table};
|
|
||||||
SQL
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Discourse.reset_active_record_cache
|
Discourse.reset_active_record_cache
|
||||||
|
@ -72,6 +72,23 @@ RSpec.describe ColumnDropper do
|
|||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should be droppable' do
|
||||||
|
name = Topic
|
||||||
|
.exec_sql("SELECT name FROM schema_migration_details LIMIT 1")
|
||||||
|
.getvalue(0, 0)
|
||||||
|
|
||||||
|
dropped_proc_called = false
|
||||||
|
ColumnDropper.drop(
|
||||||
|
table: table_name,
|
||||||
|
after_migration: name,
|
||||||
|
columns: ['email'],
|
||||||
|
delay: 0.minutes,
|
||||||
|
on_drop: ->() { dropped_proc_called = true }
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(dropped_proc_called).to eq(true)
|
||||||
|
|
||||||
|
end
|
||||||
it 'should prevent updates to the readonly column' do
|
it 'should prevent updates to the readonly column' do
|
||||||
expect do
|
expect do
|
||||||
ActiveRecord::Base.connection.raw_connection.exec <<~SQL
|
ActiveRecord::Base.connection.raw_connection.exec <<~SQL
|
||||||
|
Loading…
Reference in New Issue
Block a user