"""Added user_logins table to store login attemps

Revision ID: 38eb5f63a8a4
Revises: ac95cbd0fce
Create Date: 2015-11-17 10:56:40.862774

"""

# revision identifiers, used by Alembic.
revision = '38eb5f63a8a4'
down_revision = 'ac95cbd0fce'

from alembic import op
import sqlalchemy as sa


UPGRADE = """"""
DOWNGRADE = """"""


def iter_statements(stmts):
    for st in [x for x in stmts.split('\n') if x]:
        op.execute(st)


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_logins',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('datetime', sa.DateTime(), nullable=True),
    sa.Column('success', sa.Boolean(), nullable=True),
    sa.Column('uid', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['uid'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###
    iter_statements(UPGRADE)


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('user_logins')
    ### end Alembic commands ###
    iter_statements(DOWNGRADE)
