summaryrefslogtreecommitdiff
path: root/db/schema/knox/titles.ts
blob: 6fdf7329e1763cbb4d9f06dcb4096879f6bae021 (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
import { varchar, jsonb, timestamp, index, primaryKey } from "drizzle-orm/pg-core";
import { knoxSchema } from "./employee";

export const title = knoxSchema.table(
  "title",
  {
    companyCode: varchar("company_code", { length: 10 }).notNull(),
    titleCode: varchar("title_code", { length: 20 }).notNull(),

    titleName: varchar("title_name", { length: 100 }),
    enTitleName: varchar("en_title_name", { length: 100 }),
    sortOrder: varchar("sort_order", { length: 10 }),

    // 전체 원본 JSON 데이터 저장
    raw: jsonb("raw").notNull(),

    createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
    updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
  },
  (table) => {
    return {
      companyIdx: index("knox_title_company_idx").on(table.companyCode),
      pk: primaryKey(table.companyCode, table.titleCode),
    };
  }
);

export type KnoxTitle = typeof title.$inferSelect;
export type NewKnoxTitle = typeof title.$inferInsert;