Skip to content

Commit

Permalink
fix: update verification token table types
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdo29 committed Jul 22, 2023
1 parent e1ff84d commit 32302a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 1 addition & 2 deletions libs/db/migrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ erDiagram
User_Account ||--|{ Login_Method : "can have"
Local_Login |o--|| Login_Method : "is a"
User_Account ||--|{ User_Permission : "should have"
Verification_Tokens ||--|| User_Account : "relates to"
Verification_Token ||--|| User_Account : "relates to"
Role ||--|{ User_Permission : "relates_to"
DeityCategory {
string name
Expand Down Expand Up @@ -94,7 +94,6 @@ erDiagram
ulid id
string token
ulid user_id
timestamp expires_at
string type
}
Expand Down
3 changes: 1 addition & 2 deletions libs/db/migrations/diagram.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ erDiagram
User_Account ||--|{ Login_Method : "can have"
Local_Login |o--|| Login_Method : "is a"
User_Account ||--|{ User_Permission : "should have"
Verification_Tokens ||--|| User_Account : "relates to"
Verification_Token ||--|| User_Account : "relates to"
Role ||--|{ User_Permission : "relates_to"
DeityCategory {
string name
Expand Down Expand Up @@ -85,6 +85,5 @@ erDiagram
ulid id
string token
ulid user_id
timestamp expires_at
string type
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,29 @@ export const up = async (db: Kysely<any>): Promise<void> => {
.alterTable('local_login')
.dropConstraint('local_login_login_method_id_fkey')
.execute();
await db.schema
.alterTable('verification_token')
.dropConstraint('verification_token_user_id_fkey')
.execute();
await migrateTableColumnToUlid(db, 'verification_token', 'id', true);
await migrateTableColumnToUlid(db, 'verification_token', 'user_id');
await migrateTableColumnToUlid(db, 'role', 'id', true);
await migrateTableColumnToUlid(db, 'local_login', 'id', true);
await migrateTableColumnToUlid(db, 'local_login', 'login_method_id');
await migrateTableColumnToUlid(db, 'login_method', 'id', true);
await migrateTableColumnToUlid(db, 'login_method', 'user_id');
await migrateTableColumnToUlid(db, 'user_account', 'id', true);
await recreateForeignKey(
db,
'verification_token',
'user_id',
'user_account',
'id'
);
await db.schema
.alterTable('verification_token')
.dropColumn('expires_at')
.execute();
await migrateTableColumnToUlid(db, 'user_permission', 'id', true);
await migrateTableColumnToUlid(db, 'user_permission', 'user_id');
await migrateTableColumnToUlid(db, 'user_permission', 'role_id');
Expand Down

0 comments on commit 32302a1

Please sign in to comment.