diff --git a/app/models/orm/migrations/versions/604bf4e66c2b_.py b/app/models/orm/migrations/versions/604bf4e66c2b_.py new file mode 100644 index 00000000..8eebb37b --- /dev/null +++ b/app/models/orm/migrations/versions/604bf4e66c2b_.py @@ -0,0 +1,29 @@ +"""Add content_date_description to version_metadata + +Revision ID: 604bf4e66c2b +Revises: ef3392e8e054 +Create Date: 2024-10-31 16:52:56.571782 + +""" +from alembic import op +import sqlalchemy as sa +import sqlalchemy_utils +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '604bf4e66c2b' +down_revision = 'ef3392e8e054' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('version_metadata', sa.Column('content_date_description', sa.String(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('version_metadata', 'content_date_description') + # ### end Alembic commands ### diff --git a/app/models/orm/version_metadata.py b/app/models/orm/version_metadata.py index f1a09042..df39cc94 100644 --- a/app/models/orm/version_metadata.py +++ b/app/models/orm/version_metadata.py @@ -10,6 +10,7 @@ class VersionMetadata(Base, MetadataMixin): version = db.Column(db.String, nullable=False) content_date = db.Column(db.Date) content_start_date = db.Column(db.Date) + content_date_description = db.Column(db.String) content_end_date = db.Column(db.Date) last_update = db.Column(db.Date) description = db.Column(db.String) diff --git a/app/models/pydantic/metadata.py b/app/models/pydantic/metadata.py index 01f5a730..63e836d8 100644 --- a/app/models/pydantic/metadata.py +++ b/app/models/pydantic/metadata.py @@ -112,7 +112,10 @@ class VersionMetadata(CommonMetadata): None, description="Date range covered by the content", ) - + content_date_description: Optional[str] = Field( + None, + description="Date of content to display", + ) last_update: Optional[date] = Field( None, description="Date the data were last updated", @@ -130,6 +133,7 @@ class Config: "start_date": "2000-01-01", # TODO fix date "end_date": "2021-04-06", }, + "content_date_description": "2000 - present", } ] } @@ -159,6 +163,10 @@ class VersionMetadataUpdate(VersionMetadataIn): None, description="Date range covered by the content", ) + content_date_description: Optional[str] = Field( + None, + description="Date of content to display", + ) last_update: Optional[date] = Field( None, diff --git a/tests/utils.py b/tests/utils.py index a9a4075a..026fbf2e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -31,6 +31,7 @@ version_metadata = { "content_date_range": {"start_date": "2000-01-01", "end_date": "2021-01-01"}, + "content_date_description": "2000 - present", "last_update": "2020-01-03", "spatial_resolution": 10, "resolution_description": "10 meters", diff --git a/tests_v2/fixtures/metadata/version.py b/tests_v2/fixtures/metadata/version.py index 63a81369..07f442d2 100644 --- a/tests_v2/fixtures/metadata/version.py +++ b/tests_v2/fixtures/metadata/version.py @@ -1,5 +1,6 @@ VERSION_METADATA = { "content_date_range": {"start_date": "2000-01-01", "end_date": "2021-01-01"}, + "content_date_description": "2000 - present", "last_update": "2020-01-03", "spatial_resolution": 10, "resolution_description": "10 meters",