Add rollback snapshot controls

This commit is contained in:
ZacharyZhang-NY committed 2026-05-23 18:57:18 -04:00
1 parent 6768d19239
commit 89763592de
19 files changed
+551 -7

No files matched your search

@@ -0,0 +1,25 @@
export const rollbackSnapshotsSchema = `
create table if not exists rollback_snapshots (
id text primary key,
org_id text not null references organizations(id) on delete cascade,
migration_report_id text not null references migration_reports(id) on delete cascade,
source_database_path text not null,
source_fingerprint text not null,
source_database_sha256 text not null,
workspace_manifest_json text not null,
workspace_manifest_sha256 text not null,
delta_journal_json text not null,
restore_plan_json text not null,
active integer not null,
created_by_employee_id text references employees(id) on delete set null,
created_at text not null,
activated_at text
);
create index if not exists idx_rollback_snapshots_org_created on rollback_snapshots(org_id, created_at);
create index if not exists idx_rollback_snapshots_report on rollback_snapshots(migration_report_id);
create unique index if not exists idx_rollback_snapshots_one_active on rollback_snapshots(org_id) where active = 1;
insert into schema_migrations(version, name, applied_at)
values (20, 'rollback_snapshots', datetime('now'));
`;
@@ -18,6 +18,7 @@ import { orgGovernanceSchema } from "./migrations/016-org-governance";
import { operationsControlsSchema } from "./migrations/017-operations-controls";
import { sdlcControlsSchema } from "./migrations/018-sdlc-controls";
import { auditReplaySchema } from "./migrations/019-audit-replay";
import { rollbackSnapshotsSchema } from "./migrations/020-rollback-snapshots";
interface Migration {
version: number;
@@ -45,6 +46,7 @@ const MIGRATIONS: Migration[] = [
{ version: 17, name: "operations_controls", sql: operationsControlsSchema },
{ version: 18, name: "sdlc_controls", sql: sdlcControlsSchema },
{ version: 19, name: "audit_replay", sql: auditReplaySchema },
{ version: 20, name: "rollback_snapshots", sql: rollbackSnapshotsSchema },
];
const SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1].version;