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/public-api-commit b/libs/policyengine-simulation-persistence/public-api-commit index 00b356dd7..0495d55fa 100644 --- a/libs/policyengine-simulation-persistence/public-api-commit +++ b/libs/policyengine-simulation-persistence/public-api-commit @@ -1 +1 @@ -e0c9d2f7aa54cfc4a15740c18eb0e29eb469d6fa +41fc0151aac124aaf8829ba7f98bb0ad9a8898ad 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..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( @@ -551,6 +552,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",