style(db): standardize database source file formatting

This commit is contained in:
2026-04-07 08:09:26 -04:00
parent ae8d547486
commit 076cf8acd0
2 changed files with 50 additions and 46 deletions

View File

@@ -1,12 +1,12 @@
import { drizzle } from 'drizzle-orm/postgres-js'; import { drizzle } from "drizzle-orm/postgres-js";
import postgres from 'postgres'; import postgres from "postgres";
import * as schema from './schema'; import * as schema from "./schema";
const connectionString = process.env.DATABASE_URL!; const connectionString = process.env.DATABASE_URL!;
const client = postgres(connectionString, { const client = postgres(connectionString, {
prepare: false, prepare: false,
connect_timeout: 30, connect_timeout: 30,
idle_timeout: 30, idle_timeout: 30,
}); });
export const db = drizzle(client, { schema }); export const db = drizzle(client, { schema });

View File

@@ -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', { export const user = pgTable("user", {
id: text('id').primaryKey(), id: text("id").primaryKey(),
name: text('name'), name: text("name"),
email: text('email').notNull().unique(), email: text("email").notNull().unique(),
emailVerified: boolean('emailVerified').default(false), emailVerified: boolean("emailVerified").default(false),
image: text('image'), image: text("image"),
createdAt: timestamp('createdAt').defaultNow(), createdAt: timestamp("createdAt").defaultNow(),
updatedAt: timestamp('updatedAt').defaultNow(), updatedAt: timestamp("updatedAt").defaultNow(),
}); });
export const session = pgTable('session', { export const session = pgTable("session", {
id: text('id').primaryKey(), id: text("id").primaryKey(),
expiresAt: timestamp('expiresAt').notNull(), expiresAt: timestamp("expiresAt").notNull(),
token: text('token').notNull().unique(), token: text("token").notNull().unique(),
createdAt: timestamp('createdAt').defaultNow(), createdAt: timestamp("createdAt").defaultNow(),
updatedAt: timestamp('updatedAt').defaultNow(), updatedAt: timestamp("updatedAt").defaultNow(),
ipAddress: text('ipAddress'), ipAddress: text("ipAddress"),
userAgent: text('userAgent'), userAgent: text("userAgent"),
userId: text('userId').notNull().references(() => user.id, { onDelete: 'cascade' }), userId: text("userId")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
}); });
export const account = pgTable('account', { export const account = pgTable("account", {
id: text('id').primaryKey(), id: text("id").primaryKey(),
accountId: text('accountId').notNull(), accountId: text("accountId").notNull(),
providerId: text('providerId').notNull(), providerId: text("providerId").notNull(),
userId: text('userId').notNull().references(() => user.id, { onDelete: 'cascade' }), userId: text("userId")
accessToken: text('accessToken'), .notNull()
refreshToken: text('refreshToken'), .references(() => user.id, { onDelete: "cascade" }),
accessTokenExpiresAt: timestamp('accessTokenExpiresAt'), accessToken: text("accessToken"),
refreshTokenExpiresAt: timestamp('refreshTokenExpiresAt'), refreshToken: text("refreshToken"),
scope: text('scope'), accessTokenExpiresAt: timestamp("accessTokenExpiresAt"),
idToken: text('idToken'), refreshTokenExpiresAt: timestamp("refreshTokenExpiresAt"),
password: text('password'), scope: text("scope"),
createdAt: timestamp('createdAt').defaultNow(), idToken: text("idToken"),
updatedAt: timestamp('updatedAt').defaultNow(), password: text("password"),
createdAt: timestamp("createdAt").defaultNow(),
updatedAt: timestamp("updatedAt").defaultNow(),
}); });
export const verification = pgTable('verification', { export const verification = pgTable("verification", {
id: text('id').primaryKey(), id: text("id").primaryKey(),
identifier: text('identifier').notNull(), identifier: text("identifier").notNull(),
value: text('value').notNull(), value: text("value").notNull(),
expiresAt: timestamp('expiresAt').notNull(), expiresAt: timestamp("expiresAt").notNull(),
createdAt: timestamp('createdAt').defaultNow(), createdAt: timestamp("createdAt").defaultNow(),
updatedAt: timestamp('updatedAt').defaultNow(), updatedAt: timestamp("updatedAt").defaultNow(),
}); });