summaryrefslogtreecommitdiff
path: root/db/schema/vendorData.ts
diff options
context:
space:
mode:
Diffstat (limited to 'db/schema/vendorData.ts')
-rw-r--r--db/schema/vendorData.ts87
1 files changed, 87 insertions, 0 deletions
diff --git a/db/schema/vendorData.ts b/db/schema/vendorData.ts
index c3df6b53..5301e61a 100644
--- a/db/schema/vendorData.ts
+++ b/db/schema/vendorData.ts
@@ -41,6 +41,27 @@ export const forms = pgTable("forms", {
}
})
+export const formsPlant = pgTable("forms_plant", {
+ id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
+ projectCode: varchar("project_code", { length: 100 }).notNull(),
+ packageCode: varchar("package_code", { length: 100 }).notNull(),
+ formCode: varchar("form_code", { length: 100 }).notNull(),
+ formName: varchar("form_name", { length: 255 }).notNull(),
+ // source: varchar("source", { length: 255 }),
+ // 새로 추가된 칼럼: eng와 im
+ eng: boolean("eng").default(false).notNull(),
+ im: boolean("im").default(false).notNull(),
+ createdAt: timestamp("created_at").defaultNow().notNull(),
+ updatedAt: timestamp("updated_at").defaultNow().notNull(),
+}, (table) => {
+ return {
+ projectItemFormCodeUnique: uniqueIndex("project_item_form_code_unique").on(
+ table.projectCode,
+ table.formCode
+ ),
+ }
+})
+
// formMetas에 projectId 추가
export const formMetas = pgTable("form_metas", {
id: serial("id").primaryKey(),
@@ -73,6 +94,16 @@ export const formEntries = pgTable("form_entries", {
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
})
+export const formEntriesPlant = pgTable("form_entries_plant", {
+ id: serial("id").primaryKey(),
+ formCode: varchar("form_code", { length: 50 }).notNull(),
+ data: jsonb("data").notNull(),
+ projectCode: varchar("project_code", { length: 100 }).notNull(),
+ packageCode: varchar("package_code", { length: 100 }).notNull(),
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
+ updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
+})
+
export const tags = pgTable("tags", {
id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
contractItemId: integer("contract_item_id")
@@ -108,6 +139,42 @@ export const tags = pgTable("tags", {
};
});
+
+export const tagsPlant = pgTable("tags_plant", {
+ id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
+
+ // SEDP에서 오는 고유 식별자
+ tagIdx: varchar("tag_idx", { length: 100 }).notNull(),
+
+ // 사용자가 편집 가능한 태그 번호
+ tagNo: varchar("tag_no", { length: 100 }).notNull(),
+
+ tagType: varchar("tag_type", { length: 50 }).notNull(),
+ class: varchar("class", { length: 100 }).notNull(),
+ tagClassId: integer("tag_class_id")
+ .references(() => tagClasses.id, { onDelete: "set null" }),
+ description: text("description"),
+
+ // 동적 속성을 저장할 JSONB 컬럼 추가
+ attributes: jsonb("attributes").$type<Record<string, string>>(),
+
+ createdAt: timestamp("created_at").defaultNow().notNull(),
+ updatedAt: timestamp("updated_at").defaultNow().notNull(),
+
+ projectCode: varchar("project_code", { length: 100 }).notNull(),
+ packageCode: varchar("package_code", { length: 100 }).notNull(),
+ formId: integer("form_id"),
+
+}, (table) => {
+ return {
+ projectPackageTagIdxUnique: uniqueIndex("project_package_tag_idx_unique").on(
+ table.projectCode,
+ table.packageCode,
+ table.tagIdx
+ ),
+ }
+})
+
// tagTypes에 projectId 추가 및 복합 기본키 생성
export const tagTypes = pgTable("tag_types", {
code: varchar("code", { length: 50 }).notNull(),
@@ -334,6 +401,26 @@ export const vendorDataReportTemps = pgTable("vendor_data_report_temps", {
export type VendorDataReportTemps = typeof vendorDataReportTemps.$inferSelect;
+export const vendorDataReportTempsPlant = pgTable("vendor_data_report_temps_plant", {
+ id: serial("id").primaryKey(),
+
+ projectCode: varchar("project_code", { length: 100 }).notNull(),
+ packageCode: varchar("package_code", { length: 100 }).notNull(),
+ formId: integer("form_id")
+ .notNull()
+ .references(() => forms.id, { onDelete: "cascade" }),
+ fileName: varchar("file_name", { length: 255 }).notNull(),
+ filePath: varchar("file_path", { length: 1024 }).notNull(),
+ createdAt: timestamp("created_at", { withTimezone: true })
+ .defaultNow()
+ .notNull(),
+ updatedAt: timestamp("updated_at", { withTimezone: true })
+ .defaultNow()
+ .notNull(),
+});
+
+export type VendorDataReportTempsPlant = typeof vendorDataReportTempsPlant.$inferSelect;
+
export const formListsView = pgView("form_lists_view").as((qb) => {
return qb