diff --git a/app/models/orm/assets.py b/app/models/orm/assets.py index b5c6b3ef..b01b45d2 100644 --- a/app/models/orm/assets.py +++ b/app/models/orm/assets.py @@ -4,8 +4,8 @@ class Asset(Base): __tablename__ = "assets" asset_id = db.Column(db.UUID, primary_key=True) - dataset = db.Column(db.String, nullable=False) - version = db.Column(db.String, nullable=False) + dataset = db.Column(db.String, nullable=False, index=True) + version = db.Column(db.String, nullable=False, index=True) asset_type = db.Column(db.String, nullable=False) asset_uri = db.Column(db.String, nullable=False) status = db.Column(db.String, nullable=False, default="pending") diff --git a/app/models/orm/migrations/versions/3e524ef0525f_.py b/app/models/orm/migrations/versions/3e524ef0525f_.py new file mode 100644 index 00000000..127937ee --- /dev/null +++ b/app/models/orm/migrations/versions/3e524ef0525f_.py @@ -0,0 +1,32 @@ +"""empty message. + +Revision ID: 3e524ef0525f +Revises: 604bf4e66c2b +Create Date: 2024-12-18 00:43:46.681427 +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "3e524ef0525f" +down_revision = "604bf4e66c2b" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_index(op.f("ix_assets_dataset"), "assets", ["dataset"], unique=False) + op.create_index(op.f("ix_assets_version"), "assets", ["version"], unique=False) + op.add_column("dataset_metadata", sa.Column("subtitle", sa.String(), nullable=True)) + op.add_column("version_metadata", sa.Column("subtitle", sa.String(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("version_metadata", "subtitle") + op.drop_column("dataset_metadata", "subtitle") + op.drop_index(op.f("ix_assets_version"), table_name="assets") + op.drop_index(op.f("ix_assets_dataset"), table_name="assets") + # ### end Alembic commands ### diff --git a/app/models/orm/mixins.py b/app/models/orm/mixins.py index c1cf744d..bed984fd 100644 --- a/app/models/orm/mixins.py +++ b/app/models/orm/mixins.py @@ -3,6 +3,7 @@ class MetadataMixin: title = db.Column(db.String) + subtitle = db.Column(db.String) spatial_resolution = db.Column(db.Numeric) resolution_description = db.Column(db.String) geographic_coverage = db.Column(db.String) diff --git a/app/models/pydantic/metadata.py b/app/models/pydantic/metadata.py index 63e836d8..4c2dd0b2 100644 --- a/app/models/pydantic/metadata.py +++ b/app/models/pydantic/metadata.py @@ -3,7 +3,7 @@ from uuid import UUID from fastapi import HTTPException -from pydantic import Field, validator, BaseModel +from pydantic import BaseModel, Field, validator from pydantic.utils import GetterDict from .base import BaseRecord, StrictBaseModel @@ -34,6 +34,7 @@ class Config: class DatasetMetadata(CommonMetadata): title: Optional[str] + subtitle: Optional[str] source: Optional[str] license: Optional[str] data_language: Optional[str] @@ -51,6 +52,7 @@ class Config: "examples": [ { "title": "Deforestation alerts (GLAD-S2)", + "subtitle": "Sentinel-2 based deforestation alerts", "source": "Global Land Analysis and Discovery (GLAD), University of Maryland", "license": "[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)", "data_language": "en",