Files
lunarfront-app/packages/backend/src/db/schema/files.ts
Ryan Moon d36c6f7135 Remove multi-tenant company_id scoping from entire codebase
Drop company_id column from all 22 domain tables via migration.
Remove companyId from JWT payload, auth plugins, all service method
signatures (~215 occurrences), all route handlers (~105 occurrences),
test runner, test suites, and frontend auth store/types.

The company table stays as store settings (name, timezone). Tenant
isolation in a SaaS deployment would be at the database level (one
DB per customer) not the application level.

All 107 API tests pass. Zero TSC errors across all packages.
2026-03-29 14:58:33 -05:00

18 lines
792 B
TypeScript

import { pgTable, uuid, varchar, integer, timestamp } from 'drizzle-orm/pg-core'
export const files = pgTable('file', {
id: uuid('id').primaryKey().defaultRandom(),
path: varchar('path', { length: 1000 }).notNull(),
filename: varchar('filename', { length: 255 }).notNull(),
contentType: varchar('content_type', { length: 100 }).notNull(),
sizeBytes: integer('size_bytes').notNull(),
entityType: varchar('entity_type', { length: 100 }).notNull(),
entityId: uuid('entity_id').notNull(),
category: varchar('category', { length: 100 }).notNull(),
uploadedBy: uuid('uploaded_by'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
})
export type FileRecord = typeof files.$inferSelect
export type FileRecordInsert = typeof files.$inferInsert