Add document uploads to components (PDFs, manuals, datasheets)

- component_documents table matching device_documents structure
- Upload/delete actions on component detail page
- Documents section in sidebar with file icon, filename, delete on hover
- Devices already had document support; components now match

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 15:03:43 +07:00
parent d6b53d8ec8
commit 117646d2cb
3 changed files with 110 additions and 4 deletions
+18
View File
@@ -170,6 +170,24 @@ export const componentImages = pgTable(
(table) => [index('component_images_component_idx').on(table.componentId)]
);
// ─── Component Documents ────────────────────────────────────────────
export const componentDocuments = pgTable(
'component_documents',
{
id: uuid('id').defaultRandom().primaryKey(),
componentId: uuid('component_id')
.notNull()
.references(() => components.id, { onDelete: 'cascade' }),
filePath: text('file_path').notNull(),
originalFilename: text('original_filename').notNull(),
fileType: text('file_type'),
description: text('description'),
uploadedAt: timestamp('uploaded_at', { withTimezone: true }).defaultNow().notNull()
},
(table) => [index('component_documents_component_idx').on(table.componentId)]
);
// ─── Installation Log (append-only) ─────────────────────────────────
export const installationLog = pgTable(