Add project revision foundation
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
||||
import { projectRevisions } from "./project-revisions.js";
|
||||
|
||||
export const projectChangeSets = sqliteTable(
|
||||
"project_change_sets",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
projectRevisionId: text("project_revision_id")
|
||||
.notNull()
|
||||
.references(() => projectRevisions.id, { onDelete: "cascade" }),
|
||||
commandType: text("command_type").notNull(),
|
||||
payloadSchemaVersion: integer("payload_schema_version").notNull(),
|
||||
forwardPayloadJson: text("forward_payload_json").notNull(),
|
||||
inversePayloadJson: text("inverse_payload_json").notNull(),
|
||||
},
|
||||
(table) => [
|
||||
unique("project_change_sets_revision_unique").on(table.projectRevisionId),
|
||||
]
|
||||
);
|
||||
@@ -0,0 +1,23 @@
|
||||
import { integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
||||
import { projects } from "./projects.js";
|
||||
|
||||
export const projectRevisions = sqliteTable(
|
||||
"project_revisions",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
projectId: text("project_id")
|
||||
.notNull()
|
||||
.references(() => projects.id, { onDelete: "cascade" }),
|
||||
revisionNumber: integer("revision_number").notNull(),
|
||||
createdAtIso: text("created_at_iso").notNull(),
|
||||
actorId: text("actor_id"),
|
||||
source: text("source").notNull(),
|
||||
description: text("description"),
|
||||
},
|
||||
(table) => [
|
||||
unique("project_revisions_project_number_unique").on(
|
||||
table.projectId,
|
||||
table.revisionNumber
|
||||
),
|
||||
]
|
||||
);
|
||||
@@ -5,4 +5,5 @@ export const projects = sqliteTable("projects", {
|
||||
name: text("name").notNull(),
|
||||
singlePhaseVoltageV: integer("single_phase_voltage_v").notNull().default(230),
|
||||
threePhaseVoltageV: integer("three_phase_voltage_v").notNull().default(400),
|
||||
currentRevision: integer("current_revision").notNull().default(0),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user