42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
|
"""convert role column to table
|
||
|
|
||
|
Revision ID: 5f462d2d9d25
|
||
|
Revises: 27761560bbcb
|
||
|
Create Date: 2022-04-13 15:00:27.182898
|
||
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
from sqlalchemy.dialects import mysql
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = "5f462d2d9d25"
|
||
|
down_revision = "27761560bbcb"
|
||
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.create_table(
|
||
|
"role",
|
||
|
sa.Column("id", sa.Integer(), nullable=False),
|
||
|
sa.Column("name", sa.String(length=64), nullable=True),
|
||
|
sa.PrimaryKeyConstraint("id"),
|
||
|
)
|
||
|
op.add_column("app_role", sa.Column("role_id", sa.Integer(), nullable=True))
|
||
|
op.create_foreign_key(None, "app_role", "role", ["role_id"], ["id"])
|
||
|
op.drop_column("app_role", "role")
|
||
|
# ### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.add_column(
|
||
|
"app_role", sa.Column("role", mysql.VARCHAR(length=64), nullable=True)
|
||
|
)
|
||
|
op.drop_constraint(None, "app_role", type_="foreignkey")
|
||
|
op.drop_column("app_role", "role_id")
|
||
|
op.drop_table("role")
|
||
|
# ### end Alembic commands ###
|