Skip to content

Commit

Permalink
Add owner_id column to datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
jterry64 committed Apr 25, 2024
1 parent 945d157 commit d61f8ab
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/orm/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class Dataset(Base):
__tablename__ = "datasets"
dataset = db.Column(db.String, primary_key=True)
is_downloadable = db.Column(db.Boolean, nullable=False, default=True)
owner_id = db.Column(db.UUID, nullable=True)
# metadata = db.Column(db.JSONB, default=dict())
164 changes: 164 additions & 0 deletions app/models/orm/migrations/versions/12c171f77c58_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
"""empty message.
Revision ID: 12c171f77c58
Revises: 04fcb4f2408a
Create Date: 2024-04-25 19:23:46.786267
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "12c171f77c58"
down_revision = "04fcb4f2408a"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("raster_band_metadata")
op.drop_table("asset_metadata")
op.drop_table("aliases")
op.drop_table("field_metadata")
op.drop_column("assets", "latest_revision")
op.drop_column("assets", "source_version")
op.drop_column("assets", "revision_history")
op.add_column("datasets", sa.Column("owner_id", postgresql.UUID(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("datasets", "owner_id")
op.add_column(
"assets",
sa.Column(
"revision_history",
postgresql.ARRAY(postgresql.JSONB(astext_type=sa.Text())),
autoincrement=False,
nullable=True,
),
)
op.add_column(
"assets",
sa.Column("source_version", sa.VARCHAR(), autoincrement=False, nullable=True),
)
op.add_column(
"assets",
sa.Column("latest_revision", sa.VARCHAR(), autoincrement=False, nullable=True),
)
op.create_table(
"field_metadata",
sa.Column(
"asset_metadata_id", postgresql.UUID(), autoincrement=False, nullable=False
),
sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column("description", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("alias", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("unit", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("is_feature_info", sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column("is_filter", sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column("data_type", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(
["asset_metadata_id"],
["asset_metadata.id"],
name="asset_metadata_id_fk",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint(
"asset_metadata_id", "name", name="field_metadata_pkey"
),
)
op.create_table(
"aliases",
sa.Column("alias", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column("dataset", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column("version", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column(
"created_on",
postgresql.TIMESTAMP(),
server_default=sa.text("now()"),
autoincrement=False,
nullable=True,
),
sa.Column(
"updated_on",
postgresql.TIMESTAMP(),
server_default=sa.text("now()"),
autoincrement=False,
nullable=True,
),
sa.ForeignKeyConstraint(
["dataset", "version"],
["versions.dataset", "versions.version"],
name="fk",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("dataset", "alias", name="aliases_pkey"),
)
op.create_table(
"asset_metadata",
sa.Column(
"id",
postgresql.UUID(),
server_default=sa.text("uuid_generate_v4()"),
autoincrement=False,
nullable=False,
),
sa.Column("asset_id", postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column("resolution", sa.NUMERIC(), autoincrement=False, nullable=True),
sa.Column("min_zoom", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("max_zoom", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column(
"tags", postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=True
),
sa.ForeignKeyConstraint(
["asset_id"],
["assets.asset_id"],
name="asset_id_fk",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("id", name="asset_metadata_pkey"),
sa.UniqueConstraint("asset_id", name="asset_id_uq"),
postgresql_ignore_search_path=False,
)
op.create_table(
"raster_band_metadata",
sa.Column(
"asset_metadata_id", postgresql.UUID(), autoincrement=False, nullable=False
),
sa.Column("pixel_meaning", sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column("description", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("alias", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("unit", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("data_type", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("compression", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("no_data_value", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column(
"statistics",
postgresql.JSONB(astext_type=sa.Text()),
autoincrement=False,
nullable=True,
),
sa.Column(
"values_table",
postgresql.JSONB(astext_type=sa.Text()),
autoincrement=False,
nullable=True,
),
sa.ForeignKeyConstraint(
["asset_metadata_id"],
["asset_metadata.id"],
name="asset_metadata_id_fk",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint(
"asset_metadata_id", "pixel_meaning", name="raster_band_metadata_pkey"
),
)
# ### end Alembic commands ###

0 comments on commit d61f8ab

Please sign in to comment.