49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""fix app token
|
|
|
|
Revision ID: 0f217e90cd07
|
|
Revises: 0518a8625b50
|
|
Create Date: 2022-06-18 23:24:12.687324
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '0f217e90cd07'
|
|
down_revision = '0518a8625b50'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.add_column('app_token', sa.Column('user_id', sa.String(length=36), nullable=False))
|
|
op.add_column('app_token', sa.Column('last_used', sa.DateTime(), nullable=True))
|
|
op.create_foreign_key(None, 'app_token', 'user', ['user_id'], ['id'])
|
|
op.add_column('totp', sa.Column('last_used', sa.DateTime(), nullable=True))
|
|
tmp_table = sa.Table('_alembic_tmp_user', sa.MetaData())
|
|
op.execute(sa.schema.DropTable(tmp_table, if_exists=True))
|
|
with op.batch_alter_table('user') as batch_op:
|
|
batch_op.alter_column('enabled',
|
|
existing_type=sa.BOOLEAN(),
|
|
nullable=False,
|
|
existing_server_default=sa.text("'false'"))
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
tmp_table = sa.Table('_alembic_tmp_user', sa.MetaData())
|
|
op.execute(sa.schema.DropTable(tmp_table, if_exists=True))
|
|
with op.batch_alter_table('user') as batch_op:
|
|
batch_op.alter_column('enabled',
|
|
existing_type=sa.BOOLEAN(),
|
|
nullable=True,
|
|
existing_server_default=sa.text("'false'"))
|
|
op.drop_column('totp', 'last_used')
|
|
op.drop_constraint(None, 'app_token', type_='foreignkey')
|
|
op.drop_column('app_token', 'last_used')
|
|
op.drop_column('app_token', 'user_id')
|
|
# ### end Alembic commands ###
|