diff options
Diffstat (limited to 'db/schema/vendorRegistrations.ts')
| -rw-r--r-- | db/schema/vendorRegistrations.ts | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/db/schema/vendorRegistrations.ts b/db/schema/vendorRegistrations.ts new file mode 100644 index 00000000..308d664f --- /dev/null +++ b/db/schema/vendorRegistrations.ts @@ -0,0 +1,88 @@ +import { relations } from "drizzle-orm";
+import {
+ date,
+ integer,
+ pgTable,
+ serial,
+ text,
+ timestamp,
+ varchar,
+ decimal,
+} from "drizzle-orm/pg-core";
+import { vendors } from "./vendors";
+
+// 정규업체 등록 관리 테이블
+export const vendorRegularRegistrations = pgTable("vendor_regular_registrations", {
+ id: serial("id").primaryKey(),
+ vendorId: integer("vendor_id").notNull().references(() => vendors.id),
+ status: varchar("status", { length: 50 }).notNull().default("audit_pass"), // audit_pass, cp_submitted, cp_review, cp_finished, approval_ready, in_review, pending_approval
+ potentialCode: varchar("potential_code", { length: 20 }), // 잠재코드
+ majorItems: text("major_items"), // 주요품목 (JSON 형태로 저장)
+ registrationRequestDate: date("registration_request_date"), // 등록요청일
+ assignedDepartment: varchar("assigned_department", { length: 100 }), // 담당부서
+ assignedDepartmentCode: varchar("assigned_department_code", { length: 20 }), // 담당부서코드
+ assignedUser: varchar("assigned_user", { length: 100 }), // 담당자
+ assignedUserCode: varchar("assigned_user_code", { length: 20 }), // 담당자코드
+ remarks: text("remarks"), // 비고
+ createdAt: timestamp("created_at").defaultNow(),
+ updatedAt: timestamp("updated_at").defaultNow(),
+});
+
+// 업무담당자 정보 테이블
+export const vendorBusinessContacts = pgTable("vendor_business_contacts", {
+ id: serial("id").primaryKey(),
+ vendorId: integer("vendor_id").notNull().references(() => vendors.id),
+ contactType: varchar("contact_type", { length: 20 }).notNull(), // sales, design, delivery, quality, tax_invoice
+ contactName: varchar("contact_name", { length: 100 }).notNull(), // 담당자명
+ position: varchar("position", { length: 50 }).notNull(), // 직급
+ department: varchar("department", { length: 100 }).notNull(), // 부서
+ responsibility: varchar("responsibility", { length: 200 }).notNull(), // 담당업무
+ email: varchar("email", { length: 255 }).notNull(), // Email
+ createdAt: timestamp("created_at").defaultNow(),
+ updatedAt: timestamp("updated_at").defaultNow(),
+});
+
+// 추가정보 테이블
+export const vendorAdditionalInfo = pgTable("vendor_additional_info", {
+ id: serial("id").primaryKey(),
+ vendorId: integer("vendor_id").notNull().references(() => vendors.id),
+ businessType: varchar("business_type", { length: 50 }), // 사업유형
+ industryType: varchar("industry_type", { length: 50 }), // 산업유형
+ companySize: varchar("company_size", { length: 20 }), // 기업규모
+ revenue: decimal("revenue", { precision: 15, scale: 2 }), // 매출액
+ factoryEstablishedDate: date("factory_established_date"), // 공장설립일
+ preferredContractTerms: text("preferred_contract_terms"), // 선호계약조건
+ createdAt: timestamp("created_at").defaultNow(),
+ updatedAt: timestamp("updated_at").defaultNow(),
+});
+
+// Relations
+export const vendorRegularRegistrationsRelations = relations(
+ vendorRegularRegistrations,
+ ({ one }) => ({
+ vendor: one(vendors, {
+ fields: [vendorRegularRegistrations.vendorId],
+ references: [vendors.id],
+ }),
+ })
+);
+
+export const vendorBusinessContactsRelations = relations(
+ vendorBusinessContacts,
+ ({ one }) => ({
+ vendor: one(vendors, {
+ fields: [vendorBusinessContacts.vendorId],
+ references: [vendors.id],
+ }),
+ })
+);
+
+export const vendorAdditionalInfoRelations = relations(
+ vendorAdditionalInfo,
+ ({ one }) => ({
+ vendor: one(vendors, {
+ fields: [vendorAdditionalInfo.vendorId],
+ references: [vendors.id],
+ }),
+ })
+);
|
