-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauth.schema.ts
53 lines (49 loc) · 1.98 KB
/
auth.schema.ts
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
import { text, timestamp, boolean, pgSchema } from "drizzle-orm/pg-core";
export const authSchema = pgSchema("auth");
export const user = authSchema.table("user", {
id: text("id").notNull().primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
emailVerified: boolean("emailVerified").notNull(),
image: text("image"),
createdAt: timestamp("createdAt", { precision: 3 }).notNull(),
updatedAt: timestamp("updatedAt", { precision: 3 }).notNull(),
username: text("username").notNull().unique()
});
export const session = authSchema.table("session", {
id: text("id").notNull().primaryKey(),
expiresAt: timestamp("expiresAt", { precision: 3 }).notNull(),
token: text("token").notNull().unique(),
createdAt: timestamp("createdAt", { precision: 3 }).notNull(),
updatedAt: timestamp("updatedAt", { precision: 3 }).notNull(),
ipAddress: text("ipAddress"),
userAgent: text("userAgent"),
userId: text("userId")
.notNull()
.references(() => user.id)
});
export const account = authSchema.table("account", {
id: text("id").notNull().primaryKey(),
accountId: text("accountId").notNull(),
providerId: text("providerId").notNull(),
userId: text("userId")
.notNull()
.references(() => user.id),
accessToken: text("accessToken"),
refreshToken: text("refreshToken"),
idToken: text("idToken"),
accessTokenExpiresAt: timestamp("accessTokenExpiresAt", { precision: 3 }),
refreshTokenExpiresAt: timestamp("refreshTokenExpiresAt", { precision: 3 }),
scope: text("scope"),
password: text("password"),
createdAt: timestamp("createdAt", { precision: 3 }).notNull(),
updatedAt: timestamp("updatedAt", { precision: 3 }).notNull()
});
export const verification = authSchema.table("verification", {
id: text("id").notNull().primaryKey(),
identifier: text("identifier").notNull(),
value: text("value").notNull(),
expiresAt: timestamp("expiresAt", { precision: 3 }).notNull(),
createdAt: timestamp("createdAt", { precision: 3 }),
updatedAt: timestamp("updatedAt", { precision: 3 })
});