1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import { pgTable, varchar, timestamp, serial, boolean, text as textArea, integer } from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";
import { users } from "./users";
// 페이지별 인포메이션 관리 테이블
export const pageInformation = pgTable("page_information", {
id: serial("id").primaryKey(),
// 페이지 정보
pagePath: varchar("page_path", { length: 100 }).notNull().unique(), // 페이지 경로 (예: '/evcp/vendor-list', '/evcp/project-detail')
pageName: varchar("page_name", { length: 255 }).notNull(), // 페이지명 (menuConfig의 title에서 자동 저장)
informationContent: textArea("information_content").notNull(), // 설명 내용
// 활성화 여부
isActive: boolean("is_active").default(true).notNull(), // 활성화 여부
createdBy: integer("created_by").references(() => users.id), // 생성자
// 메타데이터
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedBy: integer("updated_by").references(() => users.id), // 수정자
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
// 첨부파일 테이블
export const informationAttachments = pgTable("information_attachments", {
id: serial("id").primaryKey(),
// 인포메이션 ID (외래키)
informationId: integer("information_id").notNull().references(() => pageInformation.id, { onDelete: "cascade" }),
// 파일 정보
fileName: varchar("file_name", { length: 255 }).notNull(), // 원본 파일명
filePath: varchar("file_path", { length: 1024 }).notNull(), // 저장된 파일 경로
fileSize: varchar("file_size", { length: 50 }).notNull(), // 파일 크기
// 메타데이터
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
// 관계 설정
export const pageInformationRelations = relations(pageInformation, ({ many }) => ({
attachments: many(informationAttachments),
}));
export const informationAttachmentsRelations = relations(informationAttachments, ({ one }) => ({
information: one(pageInformation, {
fields: [informationAttachments.informationId],
references: [pageInformation.id],
}),
}));
export type PageInformation = typeof pageInformation.$inferSelect;
export type NewPageInformation = typeof pageInformation.$inferInsert;
export type InformationAttachment = typeof informationAttachments.$inferSelect;
export type NewInformationAttachment = typeof informationAttachments.$inferInsert;
|