"""add flask security

Revision ID: 13cb12bdc9cc
Revises: <PASSWORD>
Create Date: 2022-01-22 13:05:51.977244

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '13cb12bdc9cc'
down_revision = '<PASSWORD>'
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=80), nullable=False),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('permissions', sa.UnicodeText(), nullable=True),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    op.add_column('user', sa.Column('password', sa.String(length=255), nullable=False))
    op.add_column('user', sa.Column('active', sa.Boolean(), nullable=False))
    op.add_column('user', sa.Column('fs_uniquifier', sa.String(length=64), nullable=False))
    op.add_column('user', sa.Column('confirmed_at', sa.DateTime(), nullable=True))
    op.add_column('user', sa.Column('last_login_at', sa.DateTime(), nullable=True))
    op.add_column('user', sa.Column('current_login_at', sa.DateTime(), nullable=True))
    op.add_column('user', sa.Column('last_login_ip', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('current_login_ip', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('login_count', sa.Integer(), nullable=True))
    op.add_column('user', sa.Column('tf_primary_method', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('tf_totp_secret', sa.String(length=255), nullable=True))
    op.add_column('user', sa.Column('tf_phone_number', sa.String(length=128), nullable=True))
    op.add_column('user', sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
    op.add_column('user', sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
    op.add_column('user', sa.Column('username', sa.String(length=255), nullable=True))
    op.add_column('user', sa.Column('us_totp_secrets', sa.Text(), nullable=True))
    op.add_column('user', sa.Column('us_phone_number', sa.String(length=128), nullable=True))
    op.create_unique_constraint(None, 'user', ['username'])
    op.create_unique_constraint(None, 'user', ['fs_uniquifier'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'user', type_='unique')
    op.drop_constraint(None, 'user', type_='unique')
    op.drop_column('user', 'us_phone_number')
    op.drop_column('user', 'us_totp_secrets')
    op.drop_column('user', 'username')
    op.drop_column('user', 'update_datetime')
    op.drop_column('user', 'create_datetime')
    op.drop_column('user', 'tf_phone_number')
    op.drop_column('user', 'tf_totp_secret')
    op.drop_column('user', 'tf_primary_method')
    op.drop_column('user', 'login_count')
    op.drop_column('user', 'current_login_ip')
    op.drop_column('user', 'last_login_ip')
    op.drop_column('user', 'current_login_at')
    op.drop_column('user', 'last_login_at')
    op.drop_column('user', 'confirmed_at')
    op.drop_column('user', 'fs_uniquifier')
    op.drop_column('user', 'active')
    op.drop_column('user', 'password')
    op.drop_table('roles_users')
    op.drop_table('role')
    # ### end Alembic commands ###

"""add flask security

Revision ID: 13cb12bdc9cc
Revises: <PASSWORD>
Create Date: 2022-01-22 13:05:51.977244

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '13cb12bdc9cc'
down_revision = '<PASSWORD>'
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=80), nullable=False),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('permissions', sa.UnicodeText(), nullable=True),
    sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    op.add_column('user', sa.Column('password', sa.String(length=255), nullable=False))
    op.add_column('user', sa.Column('active', sa.Boolean(), nullable=False))
    op.add_column('user', sa.Column('fs_uniquifier', sa.String(length=64), nullable=False))
    op.add_column('user', sa.Column('confirmed_at', sa.DateTime(), nullable=True))
    op.add_column('user', sa.Column('last_login_at', sa.DateTime(), nullable=True))
    op.add_column('user', sa.Column('current_login_at', sa.DateTime(), nullable=True))
    op.add_column('user', sa.Column('last_login_ip', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('current_login_ip', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('login_count', sa.Integer(), nullable=True))
    op.add_column('user', sa.Column('tf_primary_method', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('tf_totp_secret', sa.String(length=255), nullable=True))
    op.add_column('user', sa.Column('tf_phone_number', sa.String(length=128), nullable=True))
    op.add_column('user', sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
    op.add_column('user', sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
    op.add_column('user', sa.Column('username', sa.String(length=255), nullable=True))
    op.add_column('user', sa.Column('us_totp_secrets', sa.Text(), nullable=True))
    op.add_column('user', sa.Column('us_phone_number', sa.String(length=128), nullable=True))
    op.create_unique_constraint(None, 'user', ['username'])
    op.create_unique_constraint(None, 'user', ['fs_uniquifier'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'user', type_='unique')
    op.drop_constraint(None, 'user', type_='unique')
    op.drop_column('user', 'us_phone_number')
    op.drop_column('user', 'us_totp_secrets')
    op.drop_column('user', 'username')
    op.drop_column('user', 'update_datetime')
    op.drop_column('user', 'create_datetime')
    op.drop_column('user', 'tf_phone_number')
    op.drop_column('user', 'tf_totp_secret')
    op.drop_column('user', 'tf_primary_method')
    op.drop_column('user', 'login_count')
    op.drop_column('user', 'current_login_ip')
    op.drop_column('user', 'last_login_ip')
    op.drop_column('user', 'current_login_at')
    op.drop_column('user', 'last_login_at')
    op.drop_column('user', 'confirmed_at')
    op.drop_column('user', 'fs_uniquifier')
    op.drop_column('user', 'active')
    op.drop_column('user', 'password')
    op.drop_table('roles_users')
    op.drop_table('role')
    # ### end Alembic commands ###

add flask security  Revision ID: 13cb12bdc9cc Revises: <PASSWORD> Create Date: 2022-01-22 13:05:51.977244 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###