import { sql } from "drizzle-orm"; import { check, integer, sqliteTable, text, unique, } from "drizzle-orm/sqlite-core"; import { projectChangeSets } from "./project-change-sets.js"; import { projects } from "./projects.js"; export const projectHistoryStackEntries = sqliteTable( "project_history_stack_entries", { changeSetId: text("change_set_id") .primaryKey() .references(() => projectChangeSets.id, { onDelete: "cascade" }), projectId: text("project_id") .notNull() .references(() => projects.id, { onDelete: "cascade" }), stack: text("stack").notNull(), position: integer("position").notNull(), }, (table) => [ check( "project_history_stack_entries_stack_check", sql`${table.stack} in ('undo', 'redo')` ), unique("project_history_stack_entries_position_unique").on( table.projectId, table.stack, table.position ), ] );