Skip to content

Commit c248d44

Browse files
authored
Merge pull request #122 from icefoganalytics/issue-121/unable-to-create-user-second-user
Issue 121: Unable To Create User Second User
2 parents 8f61039 + 31db107 commit c248d44

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Op } from "sequelize"
2+
import type { Migration } from "@/db/umzug"
3+
4+
export const up: Migration = async ({ context: queryInterface }) => {
5+
await queryInterface.removeIndex("users", "unique_users_auth0_subject")
6+
7+
await queryInterface.addIndex("users", {
8+
name: "unique_users_auth0_subject",
9+
unique: true,
10+
fields: ["auth0_subject"],
11+
where: {
12+
auth0_subject: {
13+
[Op.not]: null,
14+
},
15+
deleted_at: null,
16+
},
17+
})
18+
}
19+
20+
export const down: Migration = async ({ context: queryInterface }) => {
21+
await queryInterface.removeIndex("users", "unique_users_auth0_subject")
22+
23+
await queryInterface.addIndex("users", {
24+
name: "unique_users_auth0_subject",
25+
unique: true,
26+
fields: ["auth0_subject"],
27+
where: {
28+
deleted_at: null,
29+
},
30+
})
31+
}

api/src/models/user.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ User.init(
292292
fields: ["auth0_subject"],
293293
name: "unique_users_auth0_subject",
294294
where: {
295+
auth0_subject: {
296+
[Op.not]: null,
297+
},
295298
deleted_at: null,
296299
},
297300
},

0 commit comments

Comments
 (0)