diff --git a/changelog.md b/changelog.md index dd50ae1..1903371 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.8.17 + +### Added + +- `operation` and additional primary keys to `idps` table + ## 0.8.16 ### Added diff --git a/src/hapi_schema/db_idps.py b/src/hapi_schema/db_idps.py index 1f1957a..88cced8 100644 --- a/src/hapi_schema/db_idps.py +++ b/src/hapi_schema/db_idps.py @@ -6,6 +6,7 @@ DateTime, ForeignKey, Integer, + String, select, ) from sqlalchemy.orm import Mapped, mapped_column, relationship @@ -46,14 +47,15 @@ class DBIDPs(Base): build_enum_using_values(DTMAssessmentType), primary_key=True ) - reporting_round: Mapped[int] = mapped_column(Integer, nullable=True) + reporting_round: Mapped[int] = mapped_column(Integer, primary_key=True) + operation: Mapped[str] = mapped_column(String, primary_key=True) population: Mapped[int] = mapped_column( Integer, nullable=False, index=True ) reference_period_start: Mapped[datetime] = mapped_column( - DateTime, nullable=False, index=True + DateTime, primary_key=True ) reference_period_end: Mapped[datetime] = mapped_column( diff --git a/src/hapi_schema/db_views_as_tables.py b/src/hapi_schema/db_views_as_tables.py index 09c4573..9a7803d 100644 --- a/src/hapi_schema/db_views_as_tables.py +++ b/src/hapi_schema/db_views_as_tables.py @@ -275,7 +275,8 @@ class DBIDPsVAT(Base): resource_hdx_id: Mapped[str] = mapped_column(String(36)) admin2_ref: Mapped[int] = mapped_column(Integer, primary_key=True) assessment_type: Mapped[str] = mapped_column(String(32), primary_key=True) - reporting_round: Mapped[int] = mapped_column(Integer, nullable=True) + reporting_round: Mapped[int] = mapped_column(Integer, primary_key=True) + operation: Mapped[str] = mapped_column(String, primary_key=True) population: Mapped[int] = mapped_column(Integer, index=True) reference_period_start: Mapped[datetime] = mapped_column( DateTime, primary_key=True diff --git a/tests/sample_data/data_idps.py b/tests/sample_data/data_idps.py index 7004330..48a1fe3 100644 --- a/tests/sample_data/data_idps.py +++ b/tests/sample_data/data_idps.py @@ -6,6 +6,7 @@ admin2_ref=2, assessment_type="BA", reporting_round=18, + operation="Operation", population=25000, reference_period_start=datetime(2024, 1, 1), reference_period_end=datetime(2024, 12, 31), diff --git a/tests/test_idps.py b/tests/test_idps.py index 196c191..f8fb03c 100644 --- a/tests/test_idps.py +++ b/tests/test_idps.py @@ -21,6 +21,7 @@ def test_idps_view(run_view_test): view_idps.c.admin2_ref == 2, view_idps.c.assessment_type == "BA", view_idps.c.reporting_round == 18, + view_idps.c.operation == "Operation", view_idps.c.population == 25000, view_idps.c.admin2_code == "FOO-001-XXX", view_idps.c.admin1_code == "FOO-001", @@ -51,6 +52,7 @@ def base_parameters(): admin2_ref=2, assessment_type="BA", reporting_round=18, + operation="operation", population=25000, reference_period_start=datetime(2020, 1, 1), reference_period_end=datetime(2020, 1, 2), diff --git a/tests/test_views_as_tables.py b/tests/test_views_as_tables.py index db97c95..1f1171f 100644 --- a/tests/test_views_as_tables.py +++ b/tests/test_views_as_tables.py @@ -225,6 +225,8 @@ def test_idps_vat(run_indexes_test, run_columns_test, run_primary_keys_test): expected_primary_keys = [ "admin2_ref", "assessment_type", + "reporting_round", + "operation", "reference_period_start", ] expected_indexes = [