Open History to see the last commit
1import { pgTable, text, timestamp, boolean } from 'drizzle-orm/pg-core'
2
3export const users = pgTable('users', {
4 id: text('id').primaryKey(),
5 name: text('name').notNull(),
6 email: text('email').notNull().unique(),
7 emailVerified: boolean('email_verified')
8 .$defaultFn(() => false)
9 .notNull(),
10 image: text('image'),
11 createdAt: timestamp('created_at')
12 .$defaultFn(() => /* @__PURE__ */ new Date())
13 .notNull(),
14 updatedAt: timestamp('updated_at')
15 .$defaultFn(() => /* @__PURE__ */ new Date())
16 .notNull(),
17})
18
19export const sessions = pgTable('sessions', {
20 id: text('id').primaryKey(),
21 expiresAt: timestamp('expires_at').notNull(),
22 token: text('token').notNull().unique(),
23 createdAt: timestamp('created_at').notNull(),
24 updatedAt: timestamp('updated_at').notNull(),
25 ipAddress: text('ip_address'),
26 userAgent: text('user_agent'),
27 userId: text('user_id')
28 .notNull()
29 .references(() => users.id, { onDelete: 'cascade' }),
30})
31
32export const accounts = pgTable('accounts', {
33 id: text('id').primaryKey(),
34 accountId: text('account_id').notNull(),
35 providerId: text('provider_id').notNull(),
36 userId: text('user_id')
37 .notNull()
38 .references(() => users.id, { onDelete: 'cascade' }),
39 accessToken: text('access_token'),
40 refreshToken: text('refresh_token'),
41 idToken: text('id_token'),
42 accessTokenExpiresAt: timestamp('access_token_expires_at'),
43 refreshTokenExpiresAt: timestamp('refresh_token_expires_at'),
44 scope: text('scope'),
45 password: text('password'),
46 createdAt: timestamp('created_at').notNull(),
47 updatedAt: timestamp('updated_at').notNull(),
48})
49
50export const verifications = pgTable('verifications', {
51 id: text('id').primaryKey(),
52 identifier: text('identifier').notNull(),
53 value: text('value').notNull(),
54 expiresAt: timestamp('expires_at').notNull(),
55 createdAt: timestamp('created_at').$defaultFn(
56 () => /* @__PURE__ */ new Date()
57 ),
58 updatedAt: timestamp('updated_at').$defaultFn(
59 () => /* @__PURE__ */ new Date()
60 ),
61})