diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-05-14 01:40:53 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-05-14 01:40:53 +0000 |
| commit | f3a2e8e2dab46ad0725fe8861395cbcb68c2bbbf (patch) | |
| tree | 5785e226d7de8435090b5d8daa0a45efe89852a2 /db/schema/setting.ts | |
| parent | 195643ba38999454c63b77fecc8902c0a91eb842 (diff) | |
(대표님) 스키마 변경사항 및 마이그레이션
Diffstat (limited to 'db/schema/setting.ts')
| -rw-r--r-- | db/schema/setting.ts | 78 |
1 files changed, 78 insertions, 0 deletions
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 + |
