Skip to content

Commit

Permalink
fix: handle enum type alteration and migration failure in setupTestDa…
Browse files Browse the repository at this point in the history
…tabase
  • Loading branch information
typeWolffo committed Aug 16, 2024
1 parent c5826ec commit fc85922
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
JWT_REFRESH_SECRET: "test_refresh"
JWT_EXPIRATION_TIME: "15min"
CORS_ORIGIN: ""
APP_URL: "http://app.example"
EMAIL_ADAPTER: "mailhog"
DATABASE_URL: ""
SMTP_HOST: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'role') THEN
CREATE TYPE role AS ENUM ('admin', 'student', 'tutor');
ELSE
ALTER TYPE role ADD VALUE IF NOT EXISTS 'tutor';
IF NOT EXISTS (SELECT 1 FROM pg_enum WHERE enumlabel = 'tutor' AND enumtypid = 'role'::regtype) THEN
ALTER TYPE role ADD VALUE 'tutor';
END IF;

IF EXISTS (SELECT 1 FROM pg_enum WHERE enumtypid = 'role'::regtype AND enumlabel = 'teacher') THEN
IF EXISTS (SELECT 1 FROM pg_enum WHERE enumlabel = 'teacher' AND enumtypid = 'role'::regtype)
AND NOT EXISTS (SELECT 1 FROM pg_enum WHERE enumlabel = 'tutor' AND enumtypid = 'role'::regtype) THEN
ALTER TYPE role RENAME VALUE 'teacher' TO 'tutor';
END IF;
END IF;
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class UsersService {
const passwordToken = crypto.randomUUID();

/**
* TODO: Add expiration of token in set-password link
* TODO: Add expiration of set password link
* https://selleolabs.atlassian.net/browse/LC-136
*/

Expand Down

0 comments on commit fc85922

Please sign in to comment.