diff options
Diffstat (limited to 'db')
| -rw-r--r-- | db/schema/items.ts | 54 |
1 files changed, 7 insertions, 47 deletions
diff --git a/db/schema/items.ts b/db/schema/items.ts index 61643759..d57fa6b4 100644 --- a/db/schema/items.ts +++ b/db/schema/items.ts @@ -1,5 +1,4 @@ -import { relations } from "drizzle-orm"; -import { pgTable, varchar, text, timestamp ,serial, integer, pgEnum} from "drizzle-orm/pg-core" +import { pgTable, varchar, text, timestamp ,serial, integer} from "drizzle-orm/pg-core" // 자재 아이템 정보 테이블 (items) - 기존 CMCTB_MAT_CLAS 테이블 매핑 (SOAP 연결 시 컬럼이 추가/삭제될 수 있음) export const items = pgTable("items", { @@ -43,47 +42,26 @@ export const materials = pgTable("materials", { export type Item = typeof items.$inferSelect export type Materials = typeof materials.$inferSelect -export const itemsRelations = relations(items, ({ many }) => ({ - shipbuilding: many(itemShipbuilding), -})); - -// 조선 기능(공종) 유형 enum 정의 -export const workTypeEnum = pgEnum('work_type', ['기장', '전장', '선실', '배관', '철의']); - -// 해양 TOP 기능(공종) 유형 enum 정의 -export const offshoreTopWorkTypeEnum = pgEnum('offshore_top_work_type', ['TM', 'TS', 'TE', 'TP']); - -// 해양 HULL 기능(공종) 유형 enum 정의 -export const offshoreHullWorkTypeEnum = pgEnum('offshore_hull_work_type', ['HA', 'HE', 'HH', 'HM', 'NC']); - //조선 아이템 테이블 //아이템코드(:자재그룹코드), 아이템이름(:아이템리스트), 공종(:workType), 선종, createdAt(:생성일), updatedAt(:수정일) export const itemShipbuilding = pgTable("item_shipbuilding", { id: serial("id").primaryKey(), - itemCode: varchar("item_code", { length: 100 }).notNull().references(() => items.itemCode, { onDelete: 'cascade' }), - workType: workTypeEnum("work_type").notNull(), + itemCode: varchar("item_code", { length: 100 }), + workType: varchar("work_type", { length: 20 }), itemList: text("item_list"), shipTypes: text("ship_types").notNull().default('OPTION'), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), }); -//조선 아이템 관계 정의 -export const itemShipbuildingRelations = relations(itemShipbuilding, ({ one }) => ({ - item: one(items, { - fields: [itemShipbuilding.itemCode], - references: [items.itemCode], - }), -})); export type ItemShipbuilding = typeof itemShipbuilding.$inferSelect; -export type ItemWithShipbuilding = Item & ItemShipbuilding; //해양 TOP 아이템 테이블 export const itemOffshoreTop = pgTable("item_offshore_top", { id: serial("id").primaryKey(), - itemCode: varchar("item_code", { length: 100 }).notNull().references(() => items.itemCode, { onDelete: 'cascade' }), - workType: offshoreTopWorkTypeEnum("work_type").notNull(), + itemCode: varchar("item_code", { length: 100 }), + workType: varchar("work_type", { length: 20 }), itemList: text("item_list"), subItemList: text("sub_item_list"), createdAt: timestamp("created_at").defaultNow().notNull(), @@ -93,32 +71,14 @@ export const itemOffshoreTop = pgTable("item_offshore_top", { //해양 HULL 아이템 테이블 export const itemOffshoreHull = pgTable("item_offshore_hull", { id: serial("id").primaryKey(), - itemCode: varchar("item_code", { length: 100 }).notNull().references(() => items.itemCode, { onDelete: 'cascade' }), - workType: offshoreHullWorkTypeEnum("work_type").notNull(), + itemCode: varchar("item_code", { length: 100 }), + workType: varchar("work_type", { length: 20 }), itemList: text("item_list"), subItemList: text("sub_item_list"), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at").defaultNow().notNull(), }); -//해양 TOP 아이템 관계 정의 -export const itemOffshoreTopRelations = relations(itemOffshoreTop, ({ one }) => ({ - item: one(items, { - fields: [itemOffshoreTop.itemCode], - references: [items.itemCode], - }), -})); - -//해양 HULL 아이템 관계 정의 -export const itemOffshoreHullRelations = relations(itemOffshoreHull, ({ one }) => ({ - item: one(items, { - fields: [itemOffshoreHull.itemCode], - references: [items.itemCode], - }), -})); - export type ItemOffshoreTop = typeof itemOffshoreTop.$inferSelect; export type ItemOffshoreHull = typeof itemOffshoreHull.$inferSelect; -export type ItemWithOffshoreTop = Item & ItemOffshoreTop; -export type ItemWithOffshoreHull = Item & ItemOffshoreHull; //각 테이블별 컬럼 변경(itemid -> itemCode)
\ No newline at end of file |
