forked from jappel/leistungsbilanz-ts
36 lines
989 B
TypeScript
36 lines
989 B
TypeScript
import {
|
|
index,
|
|
integer,
|
|
sqliteTable,
|
|
text,
|
|
unique,
|
|
} from "drizzle-orm/sqlite-core";
|
|
import { projects } from "./projects.js";
|
|
|
|
export const projectSnapshots = sqliteTable(
|
|
"project_snapshots",
|
|
{
|
|
id: text("id").primaryKey(),
|
|
projectId: text("project_id")
|
|
.notNull()
|
|
.references(() => projects.id, { onDelete: "cascade" }),
|
|
sourceRevision: integer("source_revision").notNull(),
|
|
schemaVersion: integer("schema_version").notNull(),
|
|
name: text("name").notNull(),
|
|
description: text("description"),
|
|
payloadJson: text("payload_json").notNull(),
|
|
payloadSha256: text("payload_sha256").notNull(),
|
|
createdAtIso: text("created_at_iso").notNull(),
|
|
createdByActorId: text("created_by_actor_id"),
|
|
},
|
|
(table) => [
|
|
unique("project_snapshots_project_name_unique").on(
|
|
table.projectId,
|
|
table.name
|
|
),
|
|
index("project_snapshots_project_created_idx").on(
|
|
table.projectId,
|
|
table.createdAtIso
|
|
),
|
|
]
|
|
);
|