Skip to content

Commit

Permalink
Drop deprecated user columns (#6438)
Browse files Browse the repository at this point in the history
changelog: Internal, Database, Drop deprecated user columns
  • Loading branch information
mitchellhenke authored Jun 2, 2022
1 parent 43d49f9 commit 3c13a51
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 122 deletions.
32 changes: 0 additions & 32 deletions app/controllers/users_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/concerns/deprecated_user_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module DeprecatedUserAttributes
extend ActiveSupport::Concern

DEPRECATED_ATTRIBUTES = %i[
email_fingerprint encrypted_email email confirmed_at confirmation_token confirmation_sent_at
email_fingerprint encrypted_email email confirmed_at
].freeze

def []=(attribute, value)
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class User < ApplicationRecord
self.ignored_columns = %w[totp_timestamp confirmation_token confirmation_sent_at]
self.ignored_columns = %w[totp_timestamp]
include NonNullUuid

include ::NewRelic::Agent::MethodTracer
Expand Down
18 changes: 5 additions & 13 deletions app/views/sign_up/cancellations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@
<li><%= t('users.delete.bullet_4', app_name: APP_NAME) %></li>
</ul>

<% if IdentityConfig.store.new_sign_up_cancellation_url_enabled %>
<% c.action_button(
action: ->(**tag_options, &block) do
button_to(sign_up_destroy_path, method: :delete, **tag_options, &block)
end,
) { t('forms.buttons.cancel') } %>
<% else %>
<% c.action_button(
action: ->(**tag_options, &block) do
button_to(destroy_user_path, method: :delete, **tag_options, &block)
end,
) { t('forms.buttons.cancel') } %>
<% end %>
<% c.action_button(
action: ->(**tag_options, &block) do
button_to(sign_up_destroy_path, method: :delete, **tag_options, &block)
end,
) { t('forms.buttons.cancel') } %>

<% c.action_button(
action: ->(**tag_options, &block) do
Expand Down
3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@

match '/sign_out' => 'sign_out#destroy', via: %i[get post delete]

# Deprecated
delete '/users' => 'users#destroy', as: :destroy_user

get '/restricted' => 'banned_user#show', as: :banned_user

scope '/verify', as: 'idv' do
Expand Down
19 changes: 19 additions & 0 deletions db/primary_migrate/20220602005747_drop_deprecated_user_columns.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class DropDeprecatedUserColumns < ActiveRecord::Migration[6.1]
disable_ddl_transaction!

def up
remove_index :users, column: [:confirmation_token], name: 'index_users_on_confirmation_token', algorithm: :concurrently

safety_assured do
remove_column :users, :confirmation_token
remove_column :users, :confirmation_sent_at
end
end

def down
add_column :users, :confirmation_token, :text
add_column :users, :confirmation_sent_at, :datetime

add_index :users, ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true
end
end
5 changes: 1 addition & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_05_17_103312) do
ActiveRecord::Schema.define(version: 2022_06_02_005747) do

# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
Expand Down Expand Up @@ -581,9 +581,7 @@
t.datetime "remember_created_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "confirmation_token", limit: 255
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.integer "second_factor_attempts_count", default: 0
t.string "uuid", limit: 255, null: false
t.datetime "second_factor_locked_at"
Expand All @@ -602,7 +600,6 @@
t.string "email_language", limit: 10
t.datetime "accepted_terms_at"
t.datetime "encrypted_recovery_code_digest_generated_at"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["uuid"], name: "index_users_on_uuid", unique: true
end
Expand Down
67 changes: 0 additions & 67 deletions spec/controllers/users_controller_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/support/features/session_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def user_with_piv_cac
end

def confirm_last_user
@raw_confirmation_token, = Devise.token_generator.generate(User, :confirmation_token)
@raw_confirmation_token, = Devise.token_generator.generate(EmailAddress, :confirmation_token)

User.last.email_addresses.first.update(
confirmation_token: @raw_confirmation_token, confirmation_sent_at: Time.zone.now,
Expand Down

0 comments on commit 3c13a51

Please sign in to comment.