Skip to content

Feature password expiration migration

related to Issue on JiHu

What does this MR do and why?

During our JiHu-only feature implementation for Ability to configure user password expiration date, we found some schema are required to implement this, which is big trouble for JiHu without Upstream schema change.

We understand this feature is not in Upstream roadmap as stated reasonably in the Upstream issue, but we still want to discuss the possibility for Upstream's support for JiHu-only feature' schema addition.

The detailed requirement would be:

Add the following columns to application_settings table

  • password_expiration_enabled, boolean, not null, default: false
  • password_expires_in_days, integer, not null, default: 90
  • password_expires_notice_before_days, integer, not null, default: 7

Field for user_details table

  • password_last_changed_at, timestamp, nullable, default CURRENT_TIMESTAMP

Results of discussions with upstream before this: https://gitlab.com/gitlab-jh/gitlab-jh-enablement/-/issues/248#note_1119435619

Featuren epic link : https://jihulab.com/groups/gitlab-cn/-/epics/5382

Links an issue where upstream decided not to proceed with proposed solution: #16555

Migrations

$ bin/rails db:migrate RAILS_ENV=test
main: == 20221008032350 AddPasswordExpirationMigration: migrating ===================
main: -- add_column(:application_settings, :password_expiration_enabled, :boolean, {:default=>false, :null=>false, :comment=>"JiHu-specific column"})
main:    -> 0.0028s
main: -- add_column(:application_settings, :password_expires_in_days, :integer, {:default=>90, :null=>false, :comment=>"JiHu-specific column"})
main:    -> 0.0010s
main: -- add_column(:application_settings, :password_expires_notice_before_days, :integer, {:default=>7, :null=>false, :comment=>"JiHu-specific column"})
main:    -> 0.0009s
main: == 20221008032350 AddPasswordExpirationMigration: migrated (0.0052s) ==========

main: == 20221012033107 AddPasswordLastChangedAtToUserDetails: migrating ============
main: -- add_column(:user_details, :password_last_changed_at, :datetime_with_timezone, {:comment=>"JiHu-specific column"})
main:    -> 0.0007s
main: == 20221012033107 AddPasswordLastChangedAtToUserDetails: migrated (0.0008s) ===

ci: == 20221008032350 AddPasswordExpirationMigration: migrating ===================
ci: -- add_column(:application_settings, :password_expiration_enabled, :boolean, {:default=>false, :null=>false, :comment=>"JiHu-specific column"})
ci:    -> 0.0029s
ci: -- add_column(:application_settings, :password_expires_in_days, :integer, {:default=>90, :null=>false, :comment=>"JiHu-specific column"})
ci:    -> 0.0011s
ci: -- add_column(:application_settings, :password_expires_notice_before_days, :integer, {:default=>7, :null=>false, :comment=>"JiHu-specific column"})
ci:    -> 0.0010s
ci: == 20221008032350 AddPasswordExpirationMigration: migrated (0.0051s) ==========

ci: == 20221012033107 AddPasswordLastChangedAtToUserDetails: migrating ============
ci: -- add_column(:user_details, :password_last_changed_at, :datetime_with_timezone, {:comment=>"JiHu-specific column"})
ci:    -> 0.0008s
ci: == 20221012033107 AddPasswordLastChangedAtToUserDetails: migrated (0.0008s) ===

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