Add migration to change environment_roles role column from string to
enum type. Fix tests and functions affected by the column type change.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""update environment_roles enum list
|
||||
|
||||
Revision ID: 828d8c188dce
|
||||
Revises: 5d7198d34b91
|
||||
Create Date: 2020-01-08 16:08:03.879881
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '828d8c188dce' # pragma: allowlist secret
|
||||
down_revision = '5d7198d34b91' # pragma: allowlist secret
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE environment_roles
|
||||
SET role = NULL
|
||||
"""
|
||||
)
|
||||
|
||||
op.alter_column(
|
||||
"environment_roles",
|
||||
"role",
|
||||
type_=sa.Enum(
|
||||
"ADMIN",
|
||||
"BILLING_READ",
|
||||
"CONTRIBUTOR",
|
||||
name="role",
|
||||
native_enum=False,
|
||||
),
|
||||
existing_type=sa.VARCHAR(),
|
||||
nullable=True,
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column(
|
||||
"environment_roles",
|
||||
"status",
|
||||
type_=sa.VARCHAR(),
|
||||
existing_type=sa.Enum(
|
||||
"ADMIN",
|
||||
"BILLING_READ",
|
||||
"CONTRIBUTOR",
|
||||
name="status",
|
||||
native_enum=False,
|
||||
),
|
||||
)
|
||||
# ### end Alembic commands ###
|
Reference in New Issue
Block a user