Skip to content

Commit

Permalink
feat: Change user.last_sign_in_at column to non-null with default (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencewenski authored Aug 4, 2024
1 parent c4757be commit 0c758fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ fn alter_table_add_columns() -> TableAlterStatement {
.add_column_if_not_exists(timestamp_with_time_zone_null(User::EmailConfirmationSentAt))
.add_column_if_not_exists(string_null(User::EmailConfirmationToken))
.add_column_if_not_exists(timestamp_with_time_zone_null(User::EmailConfirmedAt))
.add_column_if_not_exists(timestamp_with_time_zone_null(User::LastSignInAt))
.add_column_if_not_exists(
timestamp_with_time_zone(User::LastSignInAt).default(Expr::current_timestamp()),
)
.add_column_if_not_exists(timestamp_with_time_zone_null(User::RecoverySentAt))
.add_column_if_not_exists(string_null(User::RecoveryToken))
.add_column_if_not_exists(timestamp_with_time_zone_null(User::EmailChangeSentAt))
Expand Down
4 changes: 2 additions & 2 deletions src/migration/user/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub mod m20240714_203551_create_user_table_uuid_pk;
pub mod m20240723_070533_add_user_account_management_fields;
pub mod m20240724_005115_user_update_timestamp;
pub mod m20240729_000812_password_updated_at;
mod m20240729_002549_password_updated_at_function;
mod m20240729_002615_password_updated_at_trigger;
pub mod m20240729_002549_password_updated_at_function;
pub mod m20240729_002615_password_updated_at_trigger;
#[cfg(test)]
mod tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
source: src/migration/user/m20240723_070533_add_user_account_management_fields.rs
expression: query.to_string(PostgresQueryBuilder)
---
ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "email_confirmation_sent_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "email_confirmation_token" varchar NULL, ADD COLUMN IF NOT EXISTS "email_confirmed_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "last_sign_in_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "recovery_sent_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "recovery_token" varchar NULL, ADD COLUMN IF NOT EXISTS "email_change_sent_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "email_change_token_new" varchar NULL, ADD COLUMN IF NOT EXISTS "email_change_token_current" varchar NULL, ADD COLUMN IF NOT EXISTS "deleted_at" timestamp with time zone NULL
ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "email_confirmation_sent_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "email_confirmation_token" varchar NULL, ADD COLUMN IF NOT EXISTS "email_confirmed_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "last_sign_in_at" timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD COLUMN IF NOT EXISTS "recovery_sent_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "recovery_token" varchar NULL, ADD COLUMN IF NOT EXISTS "email_change_sent_at" timestamp with time zone NULL, ADD COLUMN IF NOT EXISTS "email_change_token_new" varchar NULL, ADD COLUMN IF NOT EXISTS "email_change_token_current" varchar NULL, ADD COLUMN IF NOT EXISTS "deleted_at" timestamp with time zone NULL

0 comments on commit 0c758fc

Please sign in to comment.