diff options
Diffstat (limited to 'db/schema')
| -rw-r--r-- | db/schema/index.ts | 1 | ||||
| -rw-r--r-- | db/schema/setting.ts | 78 | ||||
| -rw-r--r-- | db/schema/vendorDocu.ts | 3 |
3 files changed, 82 insertions, 0 deletions
diff --git a/db/schema/index.ts b/db/schema/index.ts index 537cc16c..fdd73344 100644 --- a/db/schema/index.ts +++ b/db/schema/index.ts @@ -13,3 +13,4 @@ export * from './tasks'; export * from './logs'; export * from './basicContractDocumnet'; export * from './procurementRFQ'; +export * from './setting'; diff --git a/db/schema/setting.ts b/db/schema/setting.ts new file mode 100644 index 00000000..61862bc8 --- /dev/null +++ b/db/schema/setting.ts @@ -0,0 +1,78 @@ +// db/schema/table-presets.ts +import { pgTable, text, timestamp, boolean, integer, uuid } from "drizzle-orm/pg-core" +import { json } from "drizzle-orm/pg-core" +import { z } from "zod" + +// TableSettings 타입 정의 +export interface TableSettings<TData = any> { + // 페이지네이션 + page: number + perPage: number + + // 정렬 + sort: Array<{ + id: string + desc: boolean + }> + + // 필터 + filters: Array<{ + id: string + value: any + operator?: string + type?: string + }> + joinOperator: "and" | "or" + basicFilters: Array<{ + id: string + value: any + operator?: string + type?: string + }> + basicJoinOperator: "and" | "or" + search: string + + // 날짜 범위 (선택적) + from?: string + to?: string + + // 테이블 상태 + columnVisibility: Record<string, boolean> + columnOrder: string[] + pinnedColumns: { + left: string[] + right: string[] + } + + // 기타 확장 가능한 설정들 + groupBy?: string[] + expandedRows?: string[] +} + +export const tablePresets = pgTable("table_presets", { + id: uuid("id").primaryKey().defaultRandom(), + userId: text("user_id").notNull(), + tableId: text("table_id").notNull(), // 'rfq-list', 'purchase-orders' 등 + name: text("name").notNull(), + settings: json("settings").$type<TableSettings>().notNull(), + isDefault: boolean("is_default").default(false).notNull(), + isActive: boolean("is_active").default(false).notNull(), + isShared: boolean("is_shared").default(false).notNull(), + createdBy: text("created_by"), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at").defaultNow().notNull(), +}) + +// 공유 프리셋 테이블 +export const presetShares = pgTable("preset_shares", { + id: uuid("id").primaryKey().defaultRandom(), + presetId: uuid("preset_id").references(() => tablePresets.id, { onDelete: "cascade" }).notNull(), + sharedWithUserId: text("shared_with_user_id").notNull(), + permission: text("permission").default("read").notNull(), // 'read', 'write' + createdAt: timestamp("created_at").defaultNow().notNull(), +}) + +// TypeScript 타입 추출 +export type TablePreset = typeof tablePresets.$inferSelect +export type NewTablePreset = typeof tablePresets.$inferInsert + diff --git a/db/schema/vendorDocu.ts b/db/schema/vendorDocu.ts index ce498b94..1e166e6b 100644 --- a/db/schema/vendorDocu.ts +++ b/db/schema/vendorDocu.ts @@ -11,6 +11,9 @@ export const documents = pgTable( // 주 키 id: integer("id").primaryKey().generatedAlwaysAsIdentity(), + // documentType: varchar("document_type", { length: 50 }).notNull(), + + // 어느 계약(Contract) 소속인지 contractId: integer("contract_id") .notNull() |
