summaryrefslogtreecommitdiff
path: root/db/schema/items.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-05-22 09:52:21 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-05-22 09:52:21 +0000
commit33dccde38b365206cb14e1a0cb134e07dd8fe939 (patch)
tree7c6f740f6c8562917feb817d87bbf657c3908889 /db/schema/items.ts
parent6530332aa7fd84dc0a5faf030ff2c8d82e3c81de (diff)
(최겸) 기술영업 아이템 수정(itemCode reference)
Diffstat (limited to 'db/schema/items.ts')
-rw-r--r--db/schema/items.ts24
1 files changed, 11 insertions, 13 deletions
diff --git a/db/schema/items.ts b/db/schema/items.ts
index a032de04..bf58915b 100644
--- a/db/schema/items.ts
+++ b/db/schema/items.ts
@@ -29,7 +29,7 @@ export const offshoreHullWorkTypeEnum = pgEnum('offshore_hull_work_type', ['HA',
//아이템코드(:자재그룹코드), 아이템이름(:아이템리스트), 공종(:workType), 선종, createdAt(:생성일), updatedAt(:수정일)
export const itemShipbuilding = pgTable("item_shipbuilding", {
id: serial("id").primaryKey(),
- itemId: integer("item_id").notNull().references(() => items.id, { onDelete: 'cascade' }),
+ itemCode: varchar("item_code", { length: 100 }).notNull().references(() => items.itemCode, { onDelete: 'cascade' }),
workType: workTypeEnum("work_type").notNull(),
itemList: text("item_list"),
shipTypes: text("ship_types").notNull().default('OPTION'),
@@ -37,24 +37,21 @@ export const itemShipbuilding = pgTable("item_shipbuilding", {
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
-
//조선 아이템 관계 정의
export const itemShipbuildingRelations = relations(itemShipbuilding, ({ one }) => ({
item: one(items, {
- fields: [itemShipbuilding.itemId],
- references: [items.id],
+ 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(),
- itemId: integer("item_id").notNull().references(() => items.id, { onDelete: 'cascade' }),
+ itemCode: varchar("item_code", { length: 100 }).notNull().references(() => items.itemCode, { onDelete: 'cascade' }),
workType: offshoreTopWorkTypeEnum("work_type").notNull(),
itemList: text("item_list"),
subItemList: text("sub_item_list"),
@@ -65,7 +62,7 @@ export const itemOffshoreTop = pgTable("item_offshore_top", {
//해양 HULL 아이템 테이블
export const itemOffshoreHull = pgTable("item_offshore_hull", {
id: serial("id").primaryKey(),
- itemId: integer("item_id").notNull().references(() => items.id, { onDelete: 'cascade' }),
+ itemCode: varchar("item_code", { length: 100 }).notNull().references(() => items.itemCode, { onDelete: 'cascade' }),
workType: offshoreHullWorkTypeEnum("work_type").notNull(),
itemList: text("item_list"),
subItemList: text("sub_item_list"),
@@ -76,20 +73,21 @@ export const itemOffshoreHull = pgTable("item_offshore_hull", {
//해양 TOP 아이템 관계 정의
export const itemOffshoreTopRelations = relations(itemOffshoreTop, ({ one }) => ({
item: one(items, {
- fields: [itemOffshoreTop.itemId],
- references: [items.id],
+ fields: [itemOffshoreTop.itemCode],
+ references: [items.itemCode],
}),
}));
//해양 HULL 아이템 관계 정의
export const itemOffshoreHullRelations = relations(itemOffshoreHull, ({ one }) => ({
item: one(items, {
- fields: [itemOffshoreHull.itemId],
- references: [items.id],
+ 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; \ No newline at end of file
+export type ItemWithOffshoreHull = Item & ItemOffshoreHull;
+//각 테이블별 컬럼 변경(itemid -> itemCode) \ No newline at end of file