From e9b46fcb26b831f432d11ead4f0aa2b04c154357 Mon Sep 17 00:00:00 2001 From: mcarans Date: Thu, 17 Oct 2024 18:57:51 +1300 Subject: [PATCH] Fix datetime columns --- pyproject.toml | 4 ++-- requirements.txt | 4 ++-- src/hapi_schema/db_idps.py | 9 ++------- src/hapi_schema/db_returnees.py | 7 ++----- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 794eb7f..12efb16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,9 +42,9 @@ content-type = "text/markdown" Homepage = "https://github.com/OCHA-DAP/hapi-schemas" [project.optional-dependencies] -database = ["hdx-python-database>=1.3.3"] +database = ["hdx-python-database>=1.3.4"] dev = ["pre-commit"] -test = ["hdx-python-database>=1.3.3", "psycopg[binary]", "pytest", "pytest-cov"] +test = ["hdx-python-database>=1.3.4", "psycopg[binary]", "pytest", "pytest-cov"] ######### # Hatch # diff --git a/requirements.txt b/requirements.txt index 9001db1..dbcff31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ filelock==3.16.1 # via virtualenv greenlet==3.1.1 # via sqlalchemy -hdx-python-database==1.3.3 +hdx-python-database==1.3.4 # via hapi-schema (pyproject.toml) identify==2.6.1 # via pre-commit @@ -38,7 +38,7 @@ pytest-cov==5.0.0 # via hapi-schema (pyproject.toml) pyyaml==6.0.2 # via pre-commit -sqlalchemy==2.0.35 +sqlalchemy==2.0.36 # via # hapi-schema (pyproject.toml) # hdx-python-database diff --git a/src/hapi_schema/db_idps.py b/src/hapi_schema/db_idps.py index a470be1..8c3e5be 100644 --- a/src/hapi_schema/db_idps.py +++ b/src/hapi_schema/db_idps.py @@ -3,7 +3,6 @@ from datetime import datetime from sqlalchemy import ( - DateTime, ForeignKey, Integer, String, @@ -57,13 +56,9 @@ class DBIDPs(Base): population: Mapped[int] = mapped_column( Integer, nullable=False, index=True ) - - reference_period_start: Mapped[datetime] = mapped_column( - DateTime, primary_key=True - ) - + reference_period_start: Mapped[datetime] = mapped_column(primary_key=True) reference_period_end: Mapped[datetime] = mapped_column( - DateTime, nullable=True, index=True + nullable=False, index=True ) resource = relationship(DBResource) diff --git a/src/hapi_schema/db_returnees.py b/src/hapi_schema/db_returnees.py index a98bf25..55e11a4 100644 --- a/src/hapi_schema/db_returnees.py +++ b/src/hapi_schema/db_returnees.py @@ -6,7 +6,6 @@ from datetime import datetime from sqlalchemy import ( - DateTime, ForeignKey, Integer, String, @@ -64,11 +63,9 @@ class DBReturnees(Base): population: Mapped[int] = mapped_column( Integer, nullable=False, index=True ) - reference_period_start: Mapped[datetime] = mapped_column( - DateTime, primary_key=True - ) + reference_period_start: Mapped[datetime] = mapped_column(primary_key=True) reference_period_end: Mapped[datetime] = mapped_column( - DateTime, nullable=False, index=True + nullable=False, index=True ) # resource = relationship("DBResource")