aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db/schema.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-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],
+ }),
+ }),
+);