-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathschema.ts
More file actions
66 lines (60 loc) · 2.77 KB
/
schema.ts
File metadata and controls
66 lines (60 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { sql } from "drizzle-orm";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const user = sqliteTable("user", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
emailVerified: integer("emailVerified", { mode: "boolean" }).notNull().default(false),
image: text("image"),
createdAt: integer("createdAt", { mode: "timestamp" }).notNull(),
updatedAt: integer("updatedAt", { mode: "timestamp" }).notNull(),
subscriptionId: text("subscriptionId"),
lastKeyGeneratedAt: integer("lastKeyGeneratedAt", { mode: "timestamp" }),
});
export const session = sqliteTable("session", {
id: text("id").primaryKey(),
userId: text("userId").notNull().references(() => user.id),
token: text("token").notNull(),
expiresAt: integer("expiresAt", { mode: "timestamp" }).notNull(),
ipAddress: text("ipAddress"),
userAgent: text("userAgent"),
createdAt: integer("createdAt", { mode: "timestamp" }).notNull(),
updatedAt: integer("updatedAt", { mode: "timestamp" }).notNull()
});
export const account = sqliteTable("account", {
id: text("id").primaryKey(),
userId: text("userId").notNull().references(() => user.id),
accountId: text("accountId").notNull(),
providerId: text("providerId").notNull(),
accessToken: text("accessToken"),
refreshToken: text("refreshToken"),
accessTokenExpiresAt: integer("accessTokenExpiresAt", { mode: "timestamp" }),
refreshTokenExpiresAt: integer("refreshTokenExpiresAt", { mode: "timestamp" }),
scope: text("scope"),
idToken: text("idToken"),
password: text("password"),
createdAt: integer("createdAt", { mode: "timestamp" }).notNull(),
updatedAt: integer("updatedAt", { mode: "timestamp" }).notNull()
});
export const verification = sqliteTable("verification", {
id: text("id").primaryKey(),
identifier: text("identifier").notNull(),
value: text("value").notNull(),
expiresAt: integer("expiresAt", { mode: "timestamp" }).notNull(),
createdAt: integer("createdAt", { mode: "timestamp" }).notNull(),
updatedAt: integer("updatedAt", { mode: "timestamp" }).notNull()
});
export const rateLimit = sqliteTable("rateLimit", {
id: text("id").primaryKey(),
userId: text("userId").notNull().references(() => user.id),
endpoint: text("endpoint").notNull(),
count: integer("count").notNull().default(0),
resetAt: integer("resetAt", { mode: "timestamp" }).notNull(),
createdAt: integer("createdAt", { mode: "timestamp" }).notNull(),
updatedAt: integer("updatedAt", { mode: "timestamp" }).notNull()
});
export type User = typeof user.$inferSelect;
export type Session = typeof session.$inferSelect;
export type Account = typeof account.$inferSelect;
export type Verification = typeof verification.$inferSelect;
export type RateLimit = typeof rateLimit.$inferSelect;