forked from jsocol/pystatsd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
alembic/versions/2022-05-17_add_type_field_to_variables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""add_type_field_to_variables | ||
Revision ID: 8deee2aef34b | ||
Revises: 2645c338180c | ||
Create Date: 2022-05-17 14:45:35.593266 | ||
""" | ||
from enum import Enum | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy import orm | ||
from sqlalchemy.dialects.postgresql import ENUM | ||
from sqlalchemy.dialects.postgresql import UUID | ||
|
||
from alembic import op | ||
|
||
revision = "8deee2aef34b" | ||
down_revision = "2645c338180c" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
Base = orm.declarative_base() | ||
|
||
|
||
class VariableType(Enum): | ||
free_text = "free_text" | ||
email = "email" | ||
|
||
|
||
class Variable(Base): # type: ignore | ||
__tablename__ = "variables" | ||
|
||
uuid = sa.Column( | ||
UUID(as_uuid=True), | ||
primary_key=True, | ||
) | ||
type = sa.Column( | ||
ENUM(VariableType), | ||
nullable=True, | ||
) | ||
|
||
|
||
def upgrade(): | ||
variable_type = ENUM( | ||
"free_text", | ||
"email", | ||
name="variable_type", | ||
) | ||
variable_type.create(op.get_bind()) | ||
|
||
op.add_column( | ||
"variables", | ||
sa.Column( | ||
"type", | ||
variable_type, | ||
nullable=True, | ||
), | ||
) | ||
|
||
with orm.Session(bind=op.get_bind()) as session: | ||
session.query(Variable).update({Variable.type: "free_text"}) | ||
session.commit() | ||
|
||
op.alter_column("variables", "type", nullable=False) | ||
|
||
|
||
def downgrade(): | ||
op.drop_column("variables", "type") | ||
variable_type = ENUM( | ||
"free_text", | ||
"email", | ||
name="variable_type", | ||
) | ||
variable_type.drop(op.get_bind()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
use_case_executor/domain/flow_execution/substeps/variable_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from enum import Enum | ||
|
||
|
||
class Variabletype(str, Enum): | ||
# The str inheritance is to specify the type of the values of the enum members | ||
# This is required for FastApi to handle enum parameters | ||
free_text = "free_text" | ||
email = "email" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters