diff --git a/changelog.md b/changelog.md index 8b1df22..949786d 100644 --- a/changelog.md +++ b/changelog.md @@ -17,6 +17,12 @@ Major refactoring to allow partial/incremental standardisation of subnational ge - updated `poverty\_rate\_view` and VAT to include `admin1_name` from `admin1` table - made `reference\_period\_start` part of the primary key for `population\_vat` (originally omitted in error) +## 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 884c5cf..a470be1 100644 --- a/src/hapi_schema/db_idps.py +++ b/src/hapi_schema/db_idps.py @@ -51,14 +51,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 1ac5555..4aefce1 100644 --- a/src/hapi_schema/db_views_as_tables.py +++ b/src/hapi_schema/db_views_as_tables.py @@ -301,7 +301,8 @@ class DBIDPsVAT(Base): String(512), 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 62caee5..7f7b398 100644 --- a/tests/sample_data/data_idps.py +++ b/tests/sample_data/data_idps.py @@ -8,6 +8,7 @@ provider_admin2_name="Distrito B", 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 46077ed..f2f5f20 100644 --- a/tests/test_idps.py +++ b/tests/test_idps.py @@ -23,6 +23,7 @@ def test_idps_view(run_view_test): view_idps.c.provider_admin2_name == "Distrito B", 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", @@ -55,6 +56,7 @@ def base_parameters(): provider_admin2_name="Distrito B", 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 8a73dfd..5a4e94c 100644 --- a/tests/test_views_as_tables.py +++ b/tests/test_views_as_tables.py @@ -235,6 +235,8 @@ def test_idps_vat(run_indexes_test, run_columns_test, run_primary_keys_test): "provider_admin1_name", "provider_admin2_name", "assessment_type", + "reporting_round", + "operation", "reference_period_start", ] expected_indexes = [