Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add indices on assets and subtitle field #615

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/orm/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
32 changes: 32 additions & 0 deletions app/models/orm/migrations/versions/3e524ef0525f_.py
Original file line number Diff line number Diff line change
@@ -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 ###
1 change: 1 addition & 0 deletions app/models/orm/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion app/models/pydantic/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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",
Expand Down
Loading