summaryrefslogtreecommitdiff
path: root/db/schema/items.ts
diff options
context:
space:
mode:
Diffstat (limited to 'db/schema/items.ts')
-rw-r--r--db/schema/items.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/db/schema/items.ts b/db/schema/items.ts
index d57fa6b4..102f897f 100644
--- a/db/schema/items.ts
+++ b/db/schema/items.ts
@@ -1,10 +1,10 @@
-import { pgTable, varchar, text, timestamp ,serial, integer} from "drizzle-orm/pg-core"
+import { pgTable, varchar, text, timestamp ,serial, integer, unique} from "drizzle-orm/pg-core"
// 자재 아이템 정보 테이블 (items) - 기존 CMCTB_MAT_CLAS 테이블 매핑 (SOAP 연결 시 컬럼이 추가/삭제될 수 있음)
export const items = pgTable("items", {
id: serial("id").primaryKey(), // 고유 식별자 (신규 추가)
ProjectNo: varchar("project_no", { length: 100 }).notNull(), // CLAS_CD - 아이템 코드 (자재 클래스 코드)
- itemCode: varchar("item_code", { length: 100 }).unique(), // CLAS_CD - 아이템 코드 (자재 클래스 코드)
+ itemCode: varchar("item_code", { length: 100 }).notNull(), // CLAS_CD - 아이템 코드 (자재 클래스 코드) - unique 제거
itemName: varchar("item_name", { length: 255 }).notNull(), // CLAS_NM - 아이템명 (자재 클래스명)
packageCode: varchar("package_code", { length: 255 }).notNull(), // CLAS_NM - 아이템명 (자재 클래스명)
smCode: varchar("sm_code", { length: 255 }), // CLAS_NM - 아이템명 (자재 클래스명)
@@ -19,7 +19,10 @@ export const items = pgTable("items", {
baseUnitOfMeasure: varchar("base_unit_of_measure", { length: 3 }), // BSE_UOM - 기준 단위 (Base UOM)
createdAt: timestamp("created_at").defaultNow().notNull(), // 생성일시 (신규 추가)
updatedAt: timestamp("updated_at").defaultNow().notNull(), // 수정일시 (신규 추가)
-});
+}, (table) => ({
+ // ProjectNo와 itemCode의 복합 unique constraint
+ projectItemUnique: unique("project_item_unique").on(table.ProjectNo, table.itemCode),
+}));
export const materials = pgTable("materials", {
id: serial("id").primaryKey(), // 고유 식별자 (신규 추가)