Skip to content

Migration: Add password last changed at to user details

related to Issue on JiHu

base on Feature password expiration migration !100519 (merged)

What does this MR do and why?

Perfection for base migration: Feature password expiration migration !100519 (merged)

Three migrations for user_details table:

  • Change password_last_changed_at default value from nil to now
  • Add index on password_last_changed_at

Migrations

$ bin/rails db:migrate RAILS_ENV=test
main: == 20221025043930 ChangeDefaultValueOnPasswordLastChangedAtToUserDetails: migrating 
main: -- remove_column(:user_details, :password_last_changed_at)
main:    -> 0.0014s
main: -- add_column(:user_details, :password_last_changed_at, :datetime_with_timezone, {:null=>false, :default=>#<Proc:0x000000013b9d3028 /Users/chenqiting/gdk12/gitlab/db/migrate/20221025043930_change_default_value_on_password_last_changed_at_to_user_details.rb:8 (lambda)>, :comment=>"JiHu-specific column"})
main:    -> 0.0013s
main: == 20221025043930 ChangeDefaultValueOnPasswordLastChangedAtToUserDetails: migrated (0.0031s) 

main: == 20221028022627 AddIndexOnPasswordLastChangedAtToUserDetails: migrating =====
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:user_details, :password_last_changed_at, {:name=>"index_user_details_on_password_last_changed_at", :comment=>"JiHu-specific index", :algorithm=>:concurrently})
main:    -> 0.0021s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- add_index(:user_details, :password_last_changed_at, {:name=>"index_user_details_on_password_last_changed_at", :comment=>"JiHu-specific index", :algorithm=>:concurrently})
main:    -> 0.0013s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20221028022627 AddIndexOnPasswordLastChangedAtToUserDetails: migrated (0.0077s) 

ci: == 20221025043930 ChangeDefaultValueOnPasswordLastChangedAtToUserDetails: migrating 
ci: -- remove_column(:user_details, :password_last_changed_at)
ci:    -> 0.0009s
ci: -- add_column(:user_details, :password_last_changed_at, :datetime_with_timezone, {:null=>false, :default=>#<Proc:0x000000012eca5b50 /Users/chenqiting/gdk12/gitlab/db/migrate/20221025043930_change_default_value_on_password_last_changed_at_to_user_details.rb:8 (lambda)>, :comment=>"JiHu-specific column"})
ci:    -> 0.0011s
ci: == 20221025043930 ChangeDefaultValueOnPasswordLastChangedAtToUserDetails: migrated (0.0022s) 

ci: == 20221028022627 AddIndexOnPasswordLastChangedAtToUserDetails: migrating =====
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- index_exists?(:user_details, :password_last_changed_at, {:name=>"index_user_details_on_password_last_changed_at", :comment=>"JiHu-specific index", :algorithm=>:concurrently})
ci:    -> 0.0019s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0002s
ci: -- add_index(:user_details, :password_last_changed_at, {:name=>"index_user_details_on_password_last_changed_at", :comment=>"JiHu-specific index", :algorithm=>:concurrently})
ci:    -> 0.0012s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0002s
ci: == 20221028022627 AddIndexOnPasswordLastChangedAtToUserDetails: migrated (0.0053s) 

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

@prajnamas @mtan-gitlab @chaomao

Edited by qt

Merge request reports

Loading