aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db/schema.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-07-10 20:50:19 +0000
committerMohamed Bassem <me@mbassem.com>2025-07-12 12:20:41 +0000
commit140311d7419fa2192e5149df8f589c3c3733a399 (patch)
treeddf532bbf09e4f7c947854b5515c0e8674030645 /packages/db/schema.ts
parent385f9f0b055678420e820b8ed30e595871630e58 (diff)
downloadkarakeep-140311d7419fa2192e5149df8f589c3c3733a399.tar.zst
feat: Support forget and reset password
Diffstat (limited to 'packages/db/schema.ts')
-rw-r--r--packages/db/schema.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/db/schema.ts b/packages/db/schema.ts
index 881d72ec..79cf2def 100644
--- a/packages/db/schema.ts
+++ b/packages/db/schema.ts
@@ -87,6 +87,23 @@ export const verificationTokens = sqliteTable(
(vt) => [primaryKey({ columns: [vt.identifier, vt.token] })],
);
+export const passwordResetTokens = sqliteTable(
+ "passwordResetToken",
+ {
+ id: text("id")
+ .notNull()
+ .primaryKey()
+ .$defaultFn(() => createId()),
+ userId: text("userId")
+ .notNull()
+ .references(() => users.id, { onDelete: "cascade" }),
+ token: text("token").notNull().unique(),
+ expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
+ createdAt: createdAtField(),
+ },
+ (prt) => [index("passwordResetTokens_userId_idx").on(prt.userId)],
+);
+
export const apiKeys = sqliteTable(
"apiKey",
{
@@ -727,3 +744,13 @@ export const invitesRelations = relations(invites, ({ one }) => ({
references: [users.id],
}),
}));
+
+export const passwordResetTokensRelations = relations(
+ passwordResetTokens,
+ ({ one }) => ({
+ user: one(users, {
+ fields: [passwordResetTokens.userId],
+ references: [users.id],
+ }),
+ }),
+);