diff options
Diffstat (limited to 'db/schema/techSales.ts')
| -rw-r--r-- | db/schema/techSales.ts | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/db/schema/techSales.ts b/db/schema/techSales.ts index 70d812f3..09b32500 100644 --- a/db/schema/techSales.ts +++ b/db/schema/techSales.ts @@ -41,7 +41,7 @@ import { relations } from "drizzle-orm"; import { biddingProjects } from "./projects"; import { users } from "./users"; import { itemOffshoreHull, itemOffshoreTop, itemShipbuilding } from "./items"; -import { techVendors } from "./techVendors"; +import { techVendors, techVendorContacts, techVendorPossibleItems } from "./techVendors"; // ===== 기술영업 상태 관리 상수 및 타입 ===== @@ -237,6 +237,7 @@ export const techSalesVendorQuotations = pgTable( validUntil: date("valid_until", { mode: "date" }).$type<Date>(), // === [끝] 견적 응답 정보 === + // 상태 관리 status: varchar("status", { length: 30 }) .$type<TechSalesQuotationStatus>() @@ -333,6 +334,7 @@ export const techSalesRfqCommentAttachments = pgTable("tech_sales_rfq_comment_at { onDelete: "cascade" } ), fileName: varchar("file_name", { length: 255 }).notNull(), + originalFileName: varchar("original_file_name", { length: 255 }).notNull(), fileSize: integer("file_size").notNull(), fileType: varchar("file_type", { length: 100 }), filePath: varchar("file_path", { length: 500 }).notNull(), @@ -567,4 +569,59 @@ export const techSalesVendorQuotationAttachmentsRelations = relations(techSalesV fields: [techSalesVendorQuotationAttachments.vendorId], references: [techVendors.id], }), +})); + +// ===== 기술영업 견적서-담당자 관계 테이블 ===== + +// 기술영업 벤더 견적서와 담당자의 관계 테이블 (RFQ 발송 시 어떤 담당자에게 발송했는지 추적) +export const techSalesVendorQuotationContacts = pgTable("tech_sales_vendor_quotation_contacts", { + id: serial("id").primaryKey(), + quotationId: integer("quotation_id").notNull(), + contactId: integer("contact_id").notNull(), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at").defaultNow().notNull(), +}); + +// 기술영업 견적서-담당자 관계 relations +export const techSalesVendorQuotationContactsRelations = relations(techSalesVendorQuotationContacts, ({ one }) => ({ + // 견적서 관계 + quotation: one(techSalesVendorQuotations, { + fields: [techSalesVendorQuotationContacts.quotationId], + references: [techSalesVendorQuotations.id], + }), +})); + +// ===== 기술영업 담당자별 아이템 매핑 테이블 ===== + +// 기술영업 담당자별 가능한 아이템들 매핑 테이블 (RFQ 발송 시 담당자별 아이템 정보 저장) +export const techSalesContactPossibleItems = pgTable("tech_sales_contact_possible_items", { + id: serial("id").primaryKey(), + + // 기술영업 벤더 연락처 FK + contactId: integer("contact_id") + .notNull() + .references(() => techVendorContacts.id, { onDelete: "cascade" }), + + // 기술영업 벤더 가능 아이템 FK + vendorPossibleItemId: integer("vendor_possible_item_id") + .notNull() + .references(() => techVendorPossibleItems.id, { onDelete: "cascade" }), + + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at").defaultNow().notNull(), +}); + +// 기술영업 담당자별 아이템 relations +export const techSalesContactPossibleItemsRelations = relations(techSalesContactPossibleItems, ({ one }) => ({ + // 연락처 관계 + contact: one(techVendorContacts, { + fields: [techSalesContactPossibleItems.contactId], + references: [techVendorContacts.id], + }), + + // 벤더 가능 아이템 관계 + vendorPossibleItem: one(techVendorPossibleItems, { + fields: [techSalesContactPossibleItems.vendorPossibleItemId], + references: [techVendorPossibleItems.id], + }), }));
\ No newline at end of file |
