From 45ce43a883b677e06a20a30dd695318b2a2e42c5 Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Wed, 2 Dec 2026 18:26:26 +0400 Subject: [PATCH 1/4] =?UTF-8?q?Pin=20API=20v1's=20D1=20=C2=B7=200a=20head,?= =?UTF-8?q?=20which=20adds=20uq=5Freport=5Fruns=5Fid=5Freport=20(compariso?= =?UTF-8?q?n=20fails)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PolicyEngine/policyengine-api#4386's revision 7dcd2cd14330 adds the unique constraint uq_report_runs_id_report on report_runs (id, report_id), the target of the saved reports' key to their current run. ReportRun doesn't declare it yet, so the comparison with API v1's tables at this commit fails on the missing constraint. The pin names #4386's head until it merges, as the library's README says; it moves to the merge commit before this merges. Co-Authored-By: Claude Opus 5.5 --- libs/policyengine-simulation-persistence/public-api-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/policyengine-simulation-persistence/public-api-commit b/libs/policyengine-simulation-persistence/public-api-commit index 00b356dd7..7982fa681 100644 --- a/libs/policyengine-simulation-persistence/public-api-commit +++ b/libs/policyengine-simulation-persistence/public-api-commit @@ -1 +1 @@ -e0c9d2f7aa54cfc4a15740c18eb0e29eb469d6fa +e36efee7d0b251b4ab2c87dde15113b9cd9219fd From 5547a80b003187cf3ff704c2400b3906bdbfcbcd Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:21:13 +0400 Subject: [PATCH 2/4] Declare uq_report_runs_id_report on sim's model of report_runs API v1's revision 7dcd2cd14330 (PolicyEngine/policyengine-api#4386) adds the unique constraint on report_runs (id, report_id) that a saved report's key to its current run refers to. ReportRun declares it, so the models match API v1's tables again. id is already the primary key, so the constraint refuses no row the service writes. Co-Authored-By: Claude Opus 5.5 --- changelog.d/d1-0b-report-runs-id-report.changed.md | 1 + .../src/policyengine_simulation_persistence/tables.py | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 changelog.d/d1-0b-report-runs-id-report.changed.md diff --git a/changelog.d/d1-0b-report-runs-id-report.changed.md b/changelog.d/d1-0b-report-runs-id-report.changed.md new file mode 100644 index 000000000..66bf9edaf --- /dev/null +++ b/changelog.d/d1-0b-report-runs-id-report.changed.md @@ -0,0 +1 @@ +The simulation service's model of `report_runs` declares the unique constraint `uq_report_runs_id_report` on `(id, report_id)`, which API v1 adds as the target of a saved report's key to its current run. The service reads and writes report runs as before. diff --git a/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py b/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py index 930d64137..75f138114 100644 --- a/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py +++ b/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py @@ -551,6 +551,10 @@ class ReportRun(ServiceBase): name="fk_report_runs_budget_window_run_id_budget_window_runs", ondelete="CASCADE", ), + # The target of API v1's key from a saved report + # (user_report_associations) to its current run, which keeps that run + # to the saved report's own report. + UniqueConstraint("id", "report_id", name="uq_report_runs_id_report"), UniqueConstraint( "report_id", "idempotency_key", From a0981568c2f21b43e927722b23200f86d498b3ca Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:59:54 +0400 Subject: [PATCH 3/4] =?UTF-8?q?Pin=20API=20v1's=20merge=20of=20D1=20=C2=B7?= =?UTF-8?q?=200a=20(PolicyEngine/policyengine-api#4386)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #4386 merged as 41fc0151 with a merge commit, whose tree is the same as its head e36efee7, which the comparison ran against; the pin now names a commit on API v1's master. Co-Authored-By: Claude Opus 5.5 --- libs/policyengine-simulation-persistence/public-api-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/policyengine-simulation-persistence/public-api-commit b/libs/policyengine-simulation-persistence/public-api-commit index 7982fa681..0495d55fa 100644 --- a/libs/policyengine-simulation-persistence/public-api-commit +++ b/libs/policyengine-simulation-persistence/public-api-commit @@ -1 +1 @@ -e36efee7d0b251b4ab2c87dde15113b9cd9219fd +41fc0151aac124aaf8829ba7f98bb0ad9a8898ad From 5ac9f2cc59079232fc57cee8b131952109f8943a Mon Sep 17 00:00:00 2001 From: Anthony Volk <14987227+anth-volk@users.noreply.github.com> Date: Wed, 2 Dec 2026 20:08:41 +0400 Subject: [PATCH 4/4] Name API v1's saved-report key among uq_budget_window_runs_id_report's users Review round 1's code-quality note: API v1's revision 7dcd2cd14330 also makes the constraint the target of a saved report's key to its current budget window run. Comment only. Co-Authored-By: Claude Opus 5.5 --- .../src/policyengine_simulation_persistence/tables.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py b/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py index 75f138114..b9252d652 100644 --- a/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py +++ b/libs/policyengine-simulation-persistence/src/policyengine_simulation_persistence/tables.py @@ -474,7 +474,8 @@ class BudgetWindowRun(ServiceBase): ondelete="CASCADE", ), # The target of report_runs' key, which keeps a year run to its window - # run's report. + # run's report, and of API v1's key from a saved report + # (user_report_associations) to its current budget window run. UniqueConstraint("id", "report_id", name="uq_budget_window_runs_id_report"), _completion_required("budget_window_runs"), Index(