mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 09:01:22 +02:00
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
24 lines
951 B
TypeScript
24 lines
951 B
TypeScript
import { pgTable, uuid, text, timestamp, integer } from 'drizzle-orm/pg-core';
|
|
import { relations } from 'drizzle-orm';
|
|
import { conversations } from './conversations.schema';
|
|
|
|
export const documents = pgTable('documents', {
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
conversationId: uuid('conversation_id')
|
|
.references(() => conversations.id, { onDelete: 'cascade' })
|
|
.notNull(),
|
|
version: integer('version').default(1).notNull(),
|
|
content: text('content').notNull(),
|
|
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
|
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
|
});
|
|
|
|
export const documentsRelations = relations(documents, ({ one }) => ({
|
|
conversation: one(conversations, {
|
|
fields: [documents.conversationId],
|
|
references: [conversations.id],
|
|
}),
|
|
}));
|
|
|
|
export type Document = typeof documents.$inferSelect;
|
|
export type NewDocument = typeof documents.$inferInsert;
|