Files
sub2api-cn-relay-manager/internal/store/migrations/0005_reconcile_runs_host_scope.sql
phamnazage-jpg 85d495dd16 feat(control-plane): harden host-scoped reconcile and acceptance evidence
- add batch-scoped reconcile_runs persistence and queries
- route batch detail and reconcile writes through batch_id/host_id
- refresh production boards with host-scope acceptance artifacts
- include latest real-host acceptance evidence for self_service and subscription
2026-05-18 22:22:22 +08:00

24 lines
976 B
SQL

CREATE TABLE reconcile_runs_v2 (
id INTEGER PRIMARY KEY AUTOINCREMENT,
host_id INTEGER NOT NULL,
provider_id INTEGER NOT NULL,
status TEXT NOT NULL,
summary_json TEXT NOT NULL DEFAULT '{}',
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_reconcile_runs_host FOREIGN KEY (host_id) REFERENCES hosts(id) ON DELETE CASCADE,
CONSTRAINT fk_reconcile_runs_provider FOREIGN KEY (provider_id) REFERENCES providers(id) ON DELETE CASCADE
);
INSERT INTO reconcile_runs_v2 (id, host_id, provider_id, status, summary_json, created_at)
SELECT rr.id, ib.host_id, rr.provider_id, rr.status, rr.summary_json, rr.created_at
FROM reconcile_runs rr
JOIN (
SELECT provider_id, MAX(id) AS latest_batch_id
FROM import_batches
GROUP BY provider_id
) latest ON latest.provider_id = rr.provider_id
JOIN import_batches ib ON ib.id = latest.latest_batch_id;
DROP TABLE reconcile_runs;
ALTER TABLE reconcile_runs_v2 RENAME TO reconcile_runs;