22 lines
738 B
TypeScript
22 lines
738 B
TypeScript
import { integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
|
import { circuitLists } from "./circuit-lists.js";
|
|
|
|
export const circuitSections = sqliteTable(
|
|
"circuit_sections",
|
|
{
|
|
id: text("id").primaryKey(),
|
|
circuitListId: text("circuit_list_id")
|
|
.notNull()
|
|
.references(() => circuitLists.id, { onDelete: "cascade" }),
|
|
key: text("key").notNull(),
|
|
displayName: text("display_name").notNull(),
|
|
prefix: text("prefix").notNull(),
|
|
sortOrder: integer("sort_order").notNull().default(0),
|
|
},
|
|
(table) => [
|
|
unique("circuit_sections_list_key_unique").on(table.circuitListId, table.key),
|
|
unique("circuit_sections_list_prefix_unique").on(table.circuitListId, table.prefix),
|
|
]
|
|
);
|
|
|