summaryrefslogtreecommitdiff
path: root/db/schema/notice.ts
blob: 457153498d6efe34d3c550ec3b319278ea038f79 (plain)
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
import { pgTable, varchar, text, timestamp, serial, boolean, integer } from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";
import { users } from "./users";

// 페이지별 공지사항 관리 테이블
export const notice = pgTable("notice", {
  id: serial("id").primaryKey(),
  
  // 페이지 정보
  pagePath: varchar("page_path", { length: 100 }).notNull(), // 페이지 경로 (예: '/evcp/vendor-list')
  
  // 공지사항 내용
  title: varchar("title", { length: 500 }).notNull(), // 공지사항 제목
  content: text("content").notNull(), // 공지사항 내용 (리치텍스트)
  
  // 작성자 정보
  authorId: integer("author_id").notNull().references(() => users.id), // 작성자 ID
  
  // 활성화 여부
  isActive: boolean("is_active").default(true).notNull(), // 활성화 여부

  // 팝업 설정
  isPopup: boolean("is_popup").default(false), // 팝업 여부

  // 유효기간 설정
  startAt: timestamp("start_at"), // 게시 시작 일시
  endAt: timestamp("end_at"), // 게시 종료 일시

  // '다시 보지 않기' 설정
  dontShowDuration: varchar("dont_show_duration", { length: 50 }), // 'day' 또는 null/'never'

  // 메타데이터
  createdAt: timestamp("created_at").defaultNow().notNull(),
  updatedAt: timestamp("updated_at").defaultNow().notNull(),
});

// Relations
export const noticeRelations = relations(notice, ({ one }) => ({
  author: one(users, {
    fields: [notice.authorId],
    references: [users.id],
  }),
}));

export type Notice = typeof notice.$inferSelect;
export type NewNotice = typeof notice.$inferInsert;