summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/schema/items.ts33
1 files changed, 32 insertions, 1 deletions
diff --git a/db/schema/items.ts b/db/schema/items.ts
index 1d4b0ded..9279b580 100644
--- a/db/schema/items.ts
+++ b/db/schema/items.ts
@@ -1,4 +1,5 @@
-import { pgTable, varchar, text, timestamp ,serial} from "drizzle-orm/pg-core"
+import { relations } from "drizzle-orm";
+import { pgTable, varchar, text, timestamp ,serial, integer, pgEnum} from "drizzle-orm/pg-core"
export const items = pgTable("items", {
id: serial("id").primaryKey(),
@@ -10,3 +11,33 @@ export const items = pgTable("items", {
});
export type Item = typeof items.$inferSelect
+
+export const itemsRelations = relations(items, ({ many }) => ({
+ shipbuilding: many(itemShipbuilding),
+}));
+
+// 조선 기능(공종) 유형 enum 정의
+export const workTypeEnum = pgEnum('work_type', ['기장', '전장', '선실', '배관', '철의']);
+
+//조선 아이템 테이블
+//아이템코드(:자재그룹코드), 아이템이름(:아이템리스트), 공종(:workType), 선종, createdAt(:생성일), updatedAt(:수정일)
+export const itemShipbuilding = pgTable("item_shipbuilding", {
+ id: serial("id").primaryKey(),
+ itemId: integer("item_id").notNull().references(() => items.id, { onDelete: 'cascade' }),
+ workType: workTypeEnum("work_type").notNull(),
+ shipTypes: text("ship_types").notNull().default('A-MAX'),
+});
+
+
+//조선 아이템 관계 정의
+export const itemShipbuildingRelations = relations(itemShipbuilding, ({ one }) => ({
+ item: one(items, {
+ fields: [itemShipbuilding.itemId],
+ references: [items.id],
+ }),
+}));
+
+
+
+export type ItemShipbuilding = typeof itemShipbuilding.$inferSelect;
+export type ItemWithShipbuilding = Item & ItemShipbuilding; \ No newline at end of file