claude drizzle integration

This commit is contained in:
2025-08-19 01:48:23 -04:00
parent 9942a11c0d
commit 92535f7e54
10 changed files with 135 additions and 91 deletions

12
src/db/index.ts Normal file
View File

@@ -0,0 +1,12 @@
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,
});
export const db = drizzle(client, { schema });

View File

@@ -1,7 +1,36 @@
import { integer, pgTable, varchar } from "drizzle-orm/pg-core";
import { pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core';
export const usersTable = pgTable("users", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
name: varchar({ length: 255 }).notNull(),
email: varchar({ length: 255 }).notNull().unique(),
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
email: text('email').notNull().unique(),
name: text('name'),
image: text('image'),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});
export const accounts = pgTable('accounts', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
type: text('type').notNull(),
provider: text('provider').notNull(),
providerAccountId: text('provider_account_id').notNull(),
refreshToken: text('refresh_token'),
accessToken: text('access_token'),
expiresAt: timestamp('expires_at'),
tokenType: text('token_type'),
scope: text('scope'),
idToken: text('id_token'),
sessionState: text('session_state'),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});
export const sessions = pgTable('sessions', {
id: uuid('id').primaryKey().defaultRandom(),
sessionToken: text('session_token').notNull().unique(),
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
expires: timestamp('expires').notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
});