Add persistent history stacks
This commit is contained in:
parent
2d0aa11d9c
commit
1e4dd26bb8
24 changed files with 2294 additions and 15 deletions
35
src/db/schema/project-history-stack-entries.ts
Normal file
35
src/db/schema/project-history-stack-entries.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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
|
||||
),
|
||||
]
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue