Create clean release database baseline
This commit is contained in:
@@ -37,12 +37,9 @@ import { circuitLists } from "../src/db/schema/circuit-lists.js";
|
||||
import { circuitProtectionDevices } from "../src/db/schema/circuit-protection-devices.js";
|
||||
import { circuitSections } from "../src/db/schema/circuit-sections.js";
|
||||
import { circuits } from "../src/db/schema/circuits.js";
|
||||
import { consumers } from "../src/db/schema/consumers.js";
|
||||
import { distributionBoardComponentProtectionDevices } from "../src/db/schema/distribution-board-component-protection-devices.js";
|
||||
import { distributionBoardComponents } from "../src/db/schema/distribution-board-components.js";
|
||||
import { floors } from "../src/db/schema/floors.js";
|
||||
import { legacyConsumerCircuitMigrations } from "../src/db/schema/legacy-consumer-circuit-migrations.js";
|
||||
import { legacyConsumerMigrationReports } from "../src/db/schema/legacy-consumer-migration-report.js";
|
||||
import { projectDevices } from "../src/db/schema/project-devices.js";
|
||||
import { projectRevisions } from "../src/db/schema/project-revisions.js";
|
||||
import { projectSnapshots } from "../src/db/schema/project-snapshots.js";
|
||||
@@ -282,59 +279,6 @@ function changeCompleteProjectState(context: DatabaseContext) {
|
||||
).createWithCircuitListAndDefaultSections("project-1", "UV-02");
|
||||
}
|
||||
|
||||
function seedUpgradeOnlyData(context: DatabaseContext) {
|
||||
const circuit = context.db
|
||||
.select()
|
||||
.from(circuits)
|
||||
.where(eq(circuits.id, "circuit-1"))
|
||||
.get();
|
||||
assert.ok(circuit);
|
||||
context.db
|
||||
.insert(consumers)
|
||||
.values({
|
||||
id: "consumer-1",
|
||||
projectId: "project-1",
|
||||
distributionBoardId:
|
||||
context.db.select().from(circuitLists).get()!
|
||||
.distributionBoardId,
|
||||
circuitListId: circuit.circuitListId,
|
||||
projectDeviceId: "device-1",
|
||||
roomId: "room-1",
|
||||
name: "Legacy-Pumpe",
|
||||
quantity: 1,
|
||||
installedPowerPerUnitKw: 2.5,
|
||||
demandFactor: 0.8,
|
||||
})
|
||||
.run();
|
||||
context.db
|
||||
.insert(legacyConsumerCircuitMigrations)
|
||||
.values({
|
||||
consumerId: "consumer-1",
|
||||
circuitId: "circuit-1",
|
||||
circuitDeviceRowId: "row-1",
|
||||
circuitListId: circuit.circuitListId,
|
||||
createdAtIso: "2026-07-25T00:00:00.000Z",
|
||||
})
|
||||
.run();
|
||||
context.db
|
||||
.insert(legacyConsumerMigrationReports)
|
||||
.values({
|
||||
id: "report-1",
|
||||
circuitListId: circuit.circuitListId,
|
||||
legacyConsumerCount: 1,
|
||||
createdCircuitCount: 1,
|
||||
createdDeviceRowCount: 1,
|
||||
duplicateGroupedCount: 0,
|
||||
generatedIdentifierCount: 0,
|
||||
unassignedRowCount: 0,
|
||||
warningsJson: "[]",
|
||||
generatedIdentifiersJson: "[]",
|
||||
duplicateGroupsJson: "[]",
|
||||
createdAtIso: "2026-07-25T00:00:00.000Z",
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
||||
describe("project state restore command", () => {
|
||||
it("undoes a remapped cross-project import using the persisted target hash", () => {
|
||||
const context = createTestDatabase();
|
||||
@@ -360,7 +304,7 @@ describe("project state restore command", () => {
|
||||
description: "Projektimport wiederherstellen",
|
||||
command: prepared.command,
|
||||
});
|
||||
const legacyExpectedHash = hashProjectStatePayload(
|
||||
const serializedExpectedHash = hashProjectStatePayload(
|
||||
serializeProjectStateSnapshot(
|
||||
prepared.command.payload.targetState
|
||||
)
|
||||
@@ -372,7 +316,7 @@ describe("project state restore command", () => {
|
||||
.get();
|
||||
assert.ok(storedChangeSet);
|
||||
const inverse = JSON.parse(storedChangeSet.inversePayloadJson);
|
||||
inverse.payload.expectedStateSha256 = legacyExpectedHash;
|
||||
inverse.payload.expectedStateSha256 = serializedExpectedHash;
|
||||
context.db
|
||||
.update(projectChangeSets)
|
||||
.set({ inversePayloadJson: JSON.stringify(inverse) })
|
||||
@@ -397,7 +341,6 @@ describe("project state restore command", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
const snapshots = new ProjectSnapshotRepository(context.db);
|
||||
seedUpgradeOnlyData(context);
|
||||
const snapshot = snapshots.createNamed({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
@@ -443,28 +386,6 @@ describe("project state restore command", () => {
|
||||
context.db.select().from(projectSnapshots).all().length,
|
||||
1
|
||||
);
|
||||
assert.equal(
|
||||
context.db
|
||||
.select()
|
||||
.from(legacyConsumerCircuitMigrations)
|
||||
.all().length,
|
||||
1
|
||||
);
|
||||
assert.equal(
|
||||
context.db
|
||||
.select()
|
||||
.from(legacyConsumerMigrationReports)
|
||||
.all().length,
|
||||
1
|
||||
);
|
||||
assert.equal(
|
||||
context.db
|
||||
.select({ roomId: consumers.roomId })
|
||||
.from(consumers)
|
||||
.where(eq(consumers.id, "consumer-1"))
|
||||
.get()?.roomId,
|
||||
"room-1"
|
||||
);
|
||||
|
||||
const undone = service.undo({
|
||||
projectId: "project-1",
|
||||
|
||||
Reference in New Issue
Block a user