summaryrefslogtreecommitdiff
path: root/db/schema/vendorDocu.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-04-02 09:54:08 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-04-02 09:54:08 +0000
commitdfdfae3018f8499240f48d28ce634f4a5c56e006 (patch)
tree4493b172c061fa5bf4e94c083788110eb1507f6d /db/schema/vendorDocu.ts
parent21a72eeddc74cf775e2a76e2c569de970bd62a7f (diff)
벤더 코멘트 처리
Diffstat (limited to 'db/schema/vendorDocu.ts')
-rw-r--r--db/schema/vendorDocu.ts161
1 files changed, 69 insertions, 92 deletions
diff --git a/db/schema/vendorDocu.ts b/db/schema/vendorDocu.ts
index 2e6ba5a1..ce498b94 100644
--- a/db/schema/vendorDocu.ts
+++ b/db/schema/vendorDocu.ts
@@ -1,5 +1,5 @@
-import { pgTable, integer, varchar, timestamp, date ,pgView,uniqueIndex ,jsonb} from "drizzle-orm/pg-core"
-import { eq , sql} from "drizzle-orm";
+import { pgTable, integer, varchar, timestamp, date, pgView, uniqueIndex, jsonb } from "drizzle-orm/pg-core"
+import { eq, sql } from "drizzle-orm";
import { projects } from "./projects";
import { vendors } from "./vendors";
import { contracts } from "./contract";
@@ -76,94 +76,75 @@ export const issueStages = pgTable(
}
);
- export const revisions = pgTable(
- "revisions",
- {
- id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
- issueStageId: integer("issue_stage_id").notNull(),
- revision: varchar("revision", { length: 50 }).notNull(),
- // 새로운 필드: 업로더 타입 (업체 또는 고객사)
- uploaderType: varchar("uploader_type", { length: 20 }).notNull().default("vendor"),
- // 선택적: 업로더 ID 또는 이름
- uploaderId: integer("uploader_id"),
- uploaderName: varchar("uploader_name", { length: 100 }),
- // 선택적: 추가 메타데이터
- comment: varchar("comment", { length: 500 }),
- status: varchar("status", { length: 50 }),
- approvedDate: date("approved_date"),
- createdAt: timestamp("created_at").defaultNow().notNull(),
- updatedAt: timestamp("updated_at").defaultNow().notNull(),
- },
- (table) => {
- return {
- // "issue_stage_id + revision" 조합을 유니크로 묶음 (유지)
- uniqueStageRev: uniqueIndex("unique_stage_rev").on(
- table.issueStageId,
- table.revision
- ),
- }
- }
- )
- export const documentAttachments = pgTable(
- "document_attachments",
- {
- id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
- revisionId: integer("revision_id")
- .notNull()
- .references(() => revisions.id, { onDelete: "cascade" }),
- fileName: varchar("file_name", { length: 255 }).notNull(),
- filePath: varchar("file_path", { length: 1024 }).notNull(),
- fileType: varchar("file_type", { length: 50 }),
- fileSize: integer("file_size"),
- createdAt: timestamp("created_at").defaultNow().notNull(),
- updatedAt: timestamp("updated_at").defaultNow().notNull(),
+export const revisions = pgTable(
+ "revisions",
+ {
+ id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
+ issueStageId: integer("issue_stage_id").notNull(),
+ revision: varchar("revision", { length: 50 }).notNull(),
+ // 새로운 필드: 업로더 타입 (업체 또는 고객사)
+ uploaderType: varchar("uploader_type", { length: 20 }).notNull().default("vendor"),
+ // 선택적: 업로더 ID 또는 이름
+ uploaderId: integer("uploader_id"),
+ uploaderName: varchar("uploader_name", { length: 100 }),
+ // 선택적: 추가 메타데이터
+ comment: varchar("comment", { length: 500 }),
+ status: varchar("status", { length: 50 }),
+ approvedDate: date("approved_date"),
+ createdAt: timestamp("created_at").defaultNow().notNull(),
+ updatedAt: timestamp("updated_at").defaultNow().notNull(),
+ },
+ (table) => {
+ return {
+ // "issue_stage_id + revision" 조합을 유니크로 묶음 (유지)
+ uniqueStageRev: uniqueIndex("unique_stage_rev").on(
+ table.issueStageId,
+ table.revision
+ ),
}
- )
-
+ }
+)
+export const documentAttachments = pgTable(
+ "document_attachments",
+ {
+ id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
+ revisionId: integer("revision_id")
+ .notNull()
+ .references(() => revisions.id, { onDelete: "cascade" }),
+ fileName: varchar("file_name", { length: 255 }).notNull(),
+ filePath: varchar("file_path", { length: 1024 }).notNull(),
+ fileType: varchar("file_type", { length: 50 }),
+ fileSize: integer("file_size"),
+ createdAt: timestamp("created_at").defaultNow().notNull(),
+ updatedAt: timestamp("updated_at").defaultNow().notNull(),
+ }
+)
- // export const vendorDocumentsView = pgTable("vendor_documents", {
- // vendorId: integer("vendor_id").notNull(),
- // id: integer("id").notNull(),
- // docNumber: varchar("doc_number", { length: 100 }).notNull(),
- // title: varchar("title", { length: 255 }).notNull(),
-
- // // 새로 추가된 컬럼들 (contractId, contractNo, contractName, status)
- // contractId: integer("contract_id").notNull(),
- // contractNo: varchar("contract_no", { length: 100 }).notNull(),
- // contractName: varchar("contract_name", { length: 255 }).notNull(),
- // status: varchar("status", { length: 50 }).notNull(),
-
- // createdAt: timestamp("created_at", { withTimezone: true }),
- // updatedAt: timestamp("updated_at", { withTimezone: true }),
-
- // })
+export const vendorDocumentsView = pgView("vendor_documents_view", {
+ // Match the columns in your SELECT statement
+ id: integer("id").notNull(),
+ docNumber: varchar("doc_number", { length: 100 }).notNull(),
+ title: varchar("title", { length: 255 }).notNull(),
+ status: varchar("status", { length: 50 }).notNull(),
+ issuedDate: date("issued_date"),
+ contractId: integer("contract_id").notNull(),
- export const vendorDocumentsView = pgView("vendor_documents_view", {
- // Match the columns in your SELECT statement
- id: integer("id").notNull(),
- docNumber: varchar("doc_number", { length: 100 }).notNull(),
- title: varchar("title", { length: 255 }).notNull(),
- status: varchar("status", { length: 50 }).notNull(),
- issuedDate: date("issued_date"),
-
- contractId: integer("contract_id").notNull(),
-
- latestStageId: integer("latest_stage_id"), // possibly can be null
- latestStageName: varchar("latest_stage_name", { length: 100 }),
- latestStagePlanDate: date("latest_stage_plan_date"),
- latestStageActualDate: date("latest_stage_actual_date"),
-
- latestRevisionId: integer("latest_revision_id"),
- latestRevision: varchar("latest_revision", { length: 50 }),
- latestRevisionUploaderType: varchar("latest_revision_uploader_type", { length: 20 }),
- latestRevisionUploaderName: varchar("latest_revision_uploader_name", { length: 100 }),
-
- attachmentCount: integer("attachment_count"),
-
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
- }).as(sql`
+ latestStageId: integer("latest_stage_id"), // possibly can be null
+ latestStageName: varchar("latest_stage_name", { length: 100 }),
+ latestStagePlanDate: date("latest_stage_plan_date"),
+ latestStageActualDate: date("latest_stage_actual_date"),
+
+ latestRevisionId: integer("latest_revision_id"),
+ latestRevision: varchar("latest_revision", { length: 50 }),
+ latestRevisionUploaderType: varchar("latest_revision_uploader_type", { length: 20 }),
+ latestRevisionUploaderName: varchar("latest_revision_uploader_name", { length: 100 }),
+
+ attachmentCount: integer("attachment_count"),
+
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
+}).as(sql`
SELECT
d.id,
d.doc_number,
@@ -232,8 +213,6 @@ export const issueStages = pgTable(
JOIN contracts c ON d.contract_id = c.id
`);
-
-
// 문서 + 스테이지 리스트 뷰
export const documentStagesView = pgView("document_stages_view", {
documentId: integer("document_id").notNull(),
@@ -279,7 +258,5 @@ export const documentStagesView = pgView("document_stages_view", {
FROM documents d
`);
-
- export type VendorDocumentsView = typeof vendorDocumentsView.$inferSelect
- export type DocumentStagesView = typeof documentStagesView.$inferSelect
- \ No newline at end of file
+export type VendorDocumentsView = typeof vendorDocumentsView.$inferSelect
+export type DocumentStagesView = typeof documentStagesView.$inferSelect