Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 7x 7x 7x 7x 7x 7x | import { boolean, integer, pgTable, text, timestamp, unique, uuid } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: uuid().defaultRandom().primaryKey(),
email: text().notNull().unique(),
name: text().notNull(),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
});
export const otpCodes = pgTable("otp_codes", {
id: uuid().defaultRandom().primaryKey(),
email: text().notNull(),
code: text().notNull(),
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
used: boolean().default(false).notNull(),
attempts: integer().default(0).notNull(),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
});
export const accounts = pgTable("accounts", {
id: uuid().defaultRandom().primaryKey(),
name: text().notNull(),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
});
export const memberships = pgTable(
"memberships",
{
id: uuid().defaultRandom().primaryKey(),
userId: uuid("user_id")
.notNull()
.references(() => users.id),
accountId: uuid("account_id")
.notNull()
.references(() => accounts.id),
role: text().notNull(),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
},
(t) => [unique().on(t.userId, t.accountId)],
);
export const sessions = pgTable("sessions", {
id: uuid().defaultRandom().primaryKey(),
userId: uuid("user_id")
.notNull()
.references(() => users.id),
refreshToken: text("refresh_token").notNull().unique(),
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
revokedAt: timestamp("revoked_at", { withTimezone: true }),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
});
|