feat: add Drizzle ORM database layer
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
f9c0bc0768
commit
281329a1af
@@ -0,0 +1,14 @@
|
||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
import logger from '../utils/logger.js';
|
||||
import { files } from './schema.js';
|
||||
|
||||
const client = postgres(process.env.DATABASE_URL, {
|
||||
max: 10,
|
||||
idle_timeout: 20,
|
||||
connect_timeout: 10
|
||||
});
|
||||
|
||||
export const db = drizzle(client, { schema: { files } });
|
||||
export { files };
|
||||
export default db;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { pgTable, text, bigint, timestamp, uuid } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const files = pgTable('files', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
publicId: text('public_id').unique().notNull(),
|
||||
telegramFileId: text('telegram_file_id').notNull(),
|
||||
telegramFileUniqueId: text('telegram_file_unique_id').notNull(),
|
||||
storageChatId: bigint('storage_chat_id', { mode: 'number' }).notNull(),
|
||||
storageMessageId: bigint('storage_message_id', { mode: 'number' }).notNull(),
|
||||
fileName: text('file_name').notNull(),
|
||||
mimeType: text('mime_type').notNull(),
|
||||
sizeBytes: bigint('size_bytes', { mode: 'number' }).notNull(),
|
||||
fileType: text('file_type').notNull(),
|
||||
uploaderId: bigint('uploader_id', { mode: 'number' }).notNull(),
|
||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at').defaultNow().notNull()
|
||||
});
|
||||
Reference in New Issue
Block a user