"""empty message

Revision ID: 6<PASSWORD>
Revises: <PASSWORD>
Create Date: 2019-05-01 14:49:27.914066

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '6<PASSWORD>'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None

users = sa.Table(
    'users',
    sa.MetaData(),
    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('email', sa.String(length=100)),
    sa.Column('password_hash', postgresql.BYTEA(), autoincrement=False, nullable=False),
)


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    users_credentials = op.create_table('users_credentials',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=64), nullable=False, unique=True),
    sa.Column('password_hash', sa.LargeBinary(length=256), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='users_credentials__user__fk'),
    sa.PrimaryKeyConstraint('user_id'),
    sa.UniqueConstraint('email', name='users_credentials__email__uc')
    )

    # Move email and password into new table
    op.get_bind().execute(users_credentials.insert().from_select(
        [users_credentials.c.user_id, users_credentials.c.email, users_credentials.c.password_hash],
        sa.select([users.c.id, users.c.email, users.c.password_hash])
    ))

    op.drop_constraint('users__email__uc', 'users', type_='unique')
    op.drop_column('users', 'email')
    op.drop_column('users', 'password_hash')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('password_hash', postgresql.BYTEA(), autoincrement=False, nullable=False))
    op.add_column('users', sa.Column('email', sa.VARCHAR(length=64), autoincrement=False, nullable=False))
    op.create_unique_constraint('users__email__uc', 'users', ['email'])
    op.drop_table('users_credentials')
    # ### end Alembic commands ###

"""empty message

Revision ID: 6<PASSWORD>
Revises: <PASSWORD>
Create Date: 2019-05-01 14:49:27.914066

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '6<PASSWORD>'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None

users = sa.Table(
    'users',
    sa.MetaData(),
    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('email', sa.String(length=100)),
    sa.Column('password_hash', postgresql.BYTEA(), autoincrement=False, nullable=False),
)


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    users_credentials = op.create_table('users_credentials',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=64), nullable=False, unique=True),
    sa.Column('password_hash', sa.LargeBinary(length=256), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='users_credentials__user__fk'),
    sa.PrimaryKeyConstraint('user_id'),
    sa.UniqueConstraint('email', name='users_credentials__email__uc')
    )

    # Move email and password into new table
    op.get_bind().execute(users_credentials.insert().from_select(
        [users_credentials.c.user_id, users_credentials.c.email, users_credentials.c.password_hash],
        sa.select([users.c.id, users.c.email, users.c.password_hash])
    ))

    op.drop_constraint('users__email__uc', 'users', type_='unique')
    op.drop_column('users', 'email')
    op.drop_column('users', 'password_hash')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('password_hash', postgresql.BYTEA(), autoincrement=False, nullable=False))
    op.add_column('users', sa.Column('email', sa.VARCHAR(length=64), autoincrement=False, nullable=False))
    op.create_unique_constraint('users__email__uc', 'users', ['email'])
    op.drop_table('users_credentials')
    # ### end Alembic commands ###

empty message  Revision ID: 6<PASSWORD> Revises: <PASSWORD> Create Date: 2019-05-01 14:49:27.914066 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # Move email and password into new table # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###