diff --git a/src/db/index.ts b/src/db/index.ts index ecc23cf..9c61130 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -1,12 +1,12 @@ -import { drizzle } from 'drizzle-orm/postgres-js'; -import postgres from 'postgres'; -import * as schema from './schema'; +import { drizzle } from "drizzle-orm/postgres-js"; +import postgres from "postgres"; +import * as schema from "./schema"; const connectionString = process.env.DATABASE_URL!; const client = postgres(connectionString, { - prepare: false, - connect_timeout: 30, - idle_timeout: 30, + prepare: false, + connect_timeout: 30, + idle_timeout: 30, }); -export const db = drizzle(client, { schema }); \ No newline at end of file +export const db = drizzle(client, { schema }); diff --git a/src/db/schema.ts b/src/db/schema.ts index 421df04..353e6a9 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -1,47 +1,51 @@ -import { pgTable, text, timestamp, boolean } from 'drizzle-orm/pg-core'; +import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core"; -export const user = pgTable('user', { - id: text('id').primaryKey(), - name: text('name'), - email: text('email').notNull().unique(), - emailVerified: boolean('emailVerified').default(false), - image: text('image'), - createdAt: timestamp('createdAt').defaultNow(), - updatedAt: timestamp('updatedAt').defaultNow(), +export const user = pgTable("user", { + id: text("id").primaryKey(), + name: text("name"), + email: text("email").notNull().unique(), + emailVerified: boolean("emailVerified").default(false), + image: text("image"), + createdAt: timestamp("createdAt").defaultNow(), + updatedAt: timestamp("updatedAt").defaultNow(), }); -export const session = pgTable('session', { - id: text('id').primaryKey(), - expiresAt: timestamp('expiresAt').notNull(), - token: text('token').notNull().unique(), - createdAt: timestamp('createdAt').defaultNow(), - updatedAt: timestamp('updatedAt').defaultNow(), - ipAddress: text('ipAddress'), - userAgent: text('userAgent'), - userId: text('userId').notNull().references(() => user.id, { onDelete: 'cascade' }), +export const session = pgTable("session", { + id: text("id").primaryKey(), + expiresAt: timestamp("expiresAt").notNull(), + token: text("token").notNull().unique(), + createdAt: timestamp("createdAt").defaultNow(), + updatedAt: timestamp("updatedAt").defaultNow(), + ipAddress: text("ipAddress"), + userAgent: text("userAgent"), + userId: text("userId") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), }); -export const account = pgTable('account', { - id: text('id').primaryKey(), - accountId: text('accountId').notNull(), - providerId: text('providerId').notNull(), - userId: text('userId').notNull().references(() => user.id, { onDelete: 'cascade' }), - accessToken: text('accessToken'), - refreshToken: text('refreshToken'), - accessTokenExpiresAt: timestamp('accessTokenExpiresAt'), - refreshTokenExpiresAt: timestamp('refreshTokenExpiresAt'), - scope: text('scope'), - idToken: text('idToken'), - password: text('password'), - createdAt: timestamp('createdAt').defaultNow(), - updatedAt: timestamp('updatedAt').defaultNow(), +export const account = pgTable("account", { + id: text("id").primaryKey(), + accountId: text("accountId").notNull(), + providerId: text("providerId").notNull(), + userId: text("userId") + .notNull() + .references(() => user.id, { onDelete: "cascade" }), + accessToken: text("accessToken"), + refreshToken: text("refreshToken"), + accessTokenExpiresAt: timestamp("accessTokenExpiresAt"), + refreshTokenExpiresAt: timestamp("refreshTokenExpiresAt"), + scope: text("scope"), + idToken: text("idToken"), + password: text("password"), + createdAt: timestamp("createdAt").defaultNow(), + updatedAt: timestamp("updatedAt").defaultNow(), }); -export const verification = pgTable('verification', { - id: text('id').primaryKey(), - identifier: text('identifier').notNull(), - value: text('value').notNull(), - expiresAt: timestamp('expiresAt').notNull(), - createdAt: timestamp('createdAt').defaultNow(), - updatedAt: timestamp('updatedAt').defaultNow(), +export const verification = pgTable("verification", { + id: text("id").primaryKey(), + identifier: text("identifier").notNull(), + value: text("value").notNull(), + expiresAt: timestamp("expiresAt").notNull(), + createdAt: timestamp("createdAt").defaultNow(), + updatedAt: timestamp("updatedAt").defaultNow(), });