PR C: wire real NotaryRegistry on Chain 138 (arch step 4) (#7)
Some checks failed
CI / Frontend Lint (push) Failing after 6s
CI / Frontend Type Check (push) Failing after 6s
CI / Frontend Build (push) Failing after 6s
CI / Frontend E2E Tests (push) Failing after 8s
CI / Contracts Compile (push) Has been cancelled
CI / Contracts Test (push) Has been cancelled
CI / Orchestrator Build (push) Has been cancelled
Security Scan / OWASP ZAP Scan (push) Has been cancelled
Security Scan / Dependency Vulnerability Scan (push) Has been cancelled
Some checks failed
CI / Frontend Lint (push) Failing after 6s
CI / Frontend Type Check (push) Failing after 6s
CI / Frontend Build (push) Failing after 6s
CI / Frontend E2E Tests (push) Failing after 8s
CI / Contracts Compile (push) Has been cancelled
CI / Contracts Test (push) Has been cancelled
CI / Orchestrator Build (push) Has been cancelled
Security Scan / OWASP ZAP Scan (push) Has been cancelled
Security Scan / Dependency Vulnerability Scan (push) Has been cancelled
This commit was merged in pull request #7.
This commit is contained in:
48
orchestrator/src/db/migrations/002_transaction_state.ts
Normal file
48
orchestrator/src/db/migrations/002_transaction_state.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { query } from "../postgres";
|
||||
import { TRANSACTION_STATES } from "../../types/transactionState";
|
||||
|
||||
/**
|
||||
* Migration 002 — workflow-level transaction state.
|
||||
*
|
||||
* Architecture note §8 (12-state machine) + §9 (transition table).
|
||||
*
|
||||
* Adds:
|
||||
* - plans.transaction_state column (CHECK-constrained)
|
||||
* - transaction_state_transitions append-only table
|
||||
*/
|
||||
export async function up() {
|
||||
const states = TRANSACTION_STATES.map((s) => `'${s}'`).join(",");
|
||||
|
||||
await query(
|
||||
`ALTER TABLE plans
|
||||
ADD COLUMN IF NOT EXISTS transaction_state VARCHAR(32) NOT NULL
|
||||
DEFAULT 'DRAFT'
|
||||
CHECK (transaction_state IN (${states}))`,
|
||||
);
|
||||
|
||||
await query(
|
||||
`CREATE TABLE IF NOT EXISTS transaction_state_transitions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
plan_id UUID NOT NULL REFERENCES plans(plan_id) ON DELETE CASCADE,
|
||||
from_state VARCHAR(32),
|
||||
to_state VARCHAR(32) NOT NULL CHECK (to_state IN (${states})),
|
||||
reason TEXT,
|
||||
source_event_id UUID,
|
||||
actor VARCHAR(255) NOT NULL,
|
||||
actor_role VARCHAR(32) NOT NULL,
|
||||
signature TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
)`,
|
||||
);
|
||||
|
||||
await query(
|
||||
`CREATE INDEX IF NOT EXISTS idx_tx_transitions_plan_id
|
||||
ON transaction_state_transitions(plan_id)`,
|
||||
);
|
||||
await query(
|
||||
`CREATE INDEX IF NOT EXISTS idx_tx_transitions_created_at
|
||||
ON transaction_state_transitions(created_at)`,
|
||||
);
|
||||
|
||||
console.log("Migration 002 applied: transaction_state + transitions table");
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { up as up001 } from "./001_initial_schema";
|
||||
import { up as up002 } from "./002_transaction_state";
|
||||
|
||||
/**
|
||||
* Run all migrations
|
||||
@@ -6,10 +7,10 @@ import { up as up001 } from "./001_initial_schema";
|
||||
export async function runMigration() {
|
||||
try {
|
||||
await up001();
|
||||
console.log("✅ All migrations completed");
|
||||
await up002();
|
||||
console.log("All migrations completed");
|
||||
} catch (error) {
|
||||
console.error("❌ Migration failed:", error);
|
||||
console.error("Migration failed:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user