Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
naknomum committed Oct 10, 2023
1 parent 95209e2 commit 901898d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/modules/sightings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class SightingStage(str, enum.Enum):
failed = 'failed'


class SightingMatchState(str, enum.Enum):
unreviewed = 'unreviewed'
in_progress = 'in_progress'
reviewed = 'reviewed'
unidentifiable = 'unidentifiable'


class Sighting(db.Model, HoustonModel, CustomFieldMixin, ExportMixin):
"""
Sightings database model.
Expand All @@ -68,6 +75,11 @@ class Sighting(db.Model, HoustonModel, CustomFieldMixin, ExportMixin):
db.Enum(SightingStage),
nullable=False,
)
match_state = db.Column(
db.Enum(SightingMatchState),
nullable=False,
default=SightingMatchState.unreviewed,
)
featured_asset_guid = db.Column(db.GUID, default=None, nullable=True)

# May have multiple jobs outstanding, store as Json obj dictionary, uuid_str is key,
Expand Down
58 changes: 58 additions & 0 deletions migrations/versions/53b0fec87272_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
"""empty message
Revision ID: 53b0fec87272
Revises: 2c9d119ac26b
Create Date: 2023-10-10 23:16:44.527006
"""
import sqlalchemy as sa
from alembic import op

from app.modules.sightings.models import SightingMatchState

# revision identifiers, used by Alembic.
revision = '53b0fec87272'
down_revision = '2c9d119ac26b'


def upgrade():
"""
Upgrade Semantic Description:
ENTER DESCRIPTION HERE
"""
match_state_enum = sa.Enum(
SightingMatchState,
name='sightingmatchstate',
values_callable=lambda obj: [e.value for e in obj],
)
match_state_enum.create(op.get_bind(), checkfirst=True)

# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('sighting', schema=None) as batch_op:
batch_op.add_column(
sa.Column(
'match_state',
match_state_enum,
nullable=False,
default=SightingMatchState.unreviewed.value,
server_default=SightingMatchState.unreviewed.value,
)
)

# ### end Alembic commands ###


def downgrade():
"""
Downgrade Semantic Description:
ENTER DESCRIPTION HERE
"""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('sighting', schema=None) as batch_op:
batch_op.drop_column('match_state')

# Remove the enums created as part of the upgrade above
sa.Enum(name='sightingmatchstate').drop(op.get_bind(), checkfirst=False)

# ### end Alembic commands ###

0 comments on commit 901898d

Please sign in to comment.