Skip to content

Commit

Permalink
Create jobstatus enum type in migration file.
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkrzem committed Oct 9, 2024
1 parent 71f42ef commit 5d78c6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Create Date: 2024-10-08 08:58:25.299726
"""
from alembic import op
import sqlalchemy as sa
from alembic_postgresql_enum import TableReference

# revision identifiers, used by Alembic.
Expand All @@ -14,7 +15,7 @@


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
sa.Enum('done', 'new', 'cancelled', 'removed', 'processing', name='jobstatus').create(op.get_bind())
op.sync_enum_values(
"public",
"jobstatus",
Expand All @@ -26,11 +27,9 @@ def upgrade() -> None:
],
enum_values_to_rename=[],
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.sync_enum_values(
"public",
"jobstatus",
Expand All @@ -42,4 +41,3 @@ def downgrade() -> None:
],
enum_values_to_rename=[],
)
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion src/models/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class JobView(SQLModel):
"""Public fields of mquery jobs."""

id: str
status: JobStatus = Field(sa_type=PgEnum(JobStatus, name="jobstatus", create_type=True)) # type: ignore
status: JobStatus = Field(sa_type=PgEnum(JobStatus, name="jobstatus")) # type: ignore
error: Optional[str]
rule_name: str
rule_author: str
Expand Down

0 comments on commit 5d78c6b

Please sign in to comment.