first version

This commit is contained in:
2025-09-17 16:43:44 -05:00
parent 810fad4beb
commit 6d12e7e151
28 changed files with 939 additions and 153 deletions

8
app/db/drizzle.ts Normal file
View File

@@ -0,0 +1,8 @@
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import dotenv from 'dotenv';
dotenv.config({ path: '.env' });
console.log('DATABASE_URL:', process.env.DATABASE_URL);
const queryClient = postgres(process.env.DATABASE_URL!);
export const db = drizzle(queryClient);

22
app/db/schema.ts Normal file
View File

@@ -0,0 +1,22 @@
import { pgTable, serial, text, integer, timestamp, boolean } from 'drizzle-orm/pg-core';
export const domains = pgTable('domains', {
id: serial('id').primaryKey(),
bucket: text('bucket').unique().notNull(),
domain: text('domain').notNull(),
});
export const emails = pgTable('emails', {
id: serial('id').primaryKey(),
domainId: integer('domain_id').references(() => domains.id).notNull(),
s3Key: text('s3_key').unique().notNull(),
from: text('from'),
to: text('to').array(),
cc: text('cc').array(),
bcc: text('bcc').array(),
subject: text('subject'),
html: text('html'),
raw: text('raw'),
processed: boolean('processed').default(false),
date: timestamp('date'),
});