refactor(database): 🐛 Don't allow token userId to be null

This commit is contained in:
Jesse Wierzbinski 2024-04-17 15:54:30 -10:00
parent 633e92d4e9
commit 203ea4b482
No known key found for this signature in database
4 changed files with 1979 additions and 4 deletions

View file

@ -0,0 +1 @@
ALTER TABLE "Tokens" ALTER COLUMN "userId" SET NOT NULL;

File diff suppressed because it is too large Load diff

View file

@ -106,6 +106,13 @@
"when": 1713389937821,
"tag": "0014_wonderful_sandman",
"breakpoints": true
},
{
"idx": 15,
"version": "5",
"when": 1713399438164,
"tag": "0015_easy_mojo",
"breakpoints": true
}
]
}

View file

@ -210,10 +210,12 @@ export const Tokens = pgTable("Tokens", {
createdAt: timestamp("created_at", { precision: 3, mode: "string" })
.defaultNow()
.notNull(),
userId: uuid("userId").references(() => Users.id, {
userId: uuid("userId")
.references(() => Users.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
})
.notNull(),
applicationId: uuid("applicationId").references(() => Applications.id, {
onDelete: "cascade",
onUpdate: "cascade",