first version
This commit is contained in:
8
app/db/drizzle.ts
Normal file
8
app/db/drizzle.ts
Normal 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
22
app/db/schema.ts
Normal 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'),
|
||||
});
|
||||
Reference in New Issue
Block a user