mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
19 lines
763 B
TypeScript
19 lines
763 B
TypeScript
|
|
import { pgTable, uuid, text, timestamp, index, uniqueIndex } from "drizzle-orm/pg-core";
|
||
|
|
import { companies } from "./companies.js";
|
||
|
|
|
||
|
|
export const labels = pgTable(
|
||
|
|
"labels",
|
||
|
|
{
|
||
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
||
|
|
companyId: uuid("company_id").notNull().references(() => companies.id, { onDelete: "cascade" }),
|
||
|
|
name: text("name").notNull(),
|
||
|
|
color: text("color").notNull(),
|
||
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||
|
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||
|
|
},
|
||
|
|
(table) => ({
|
||
|
|
companyIdx: index("labels_company_idx").on(table.companyId),
|
||
|
|
companyNameIdx: uniqueIndex("labels_company_name_idx").on(table.companyId, table.name),
|
||
|
|
}),
|
||
|
|
);
|