"""disabled_user

Revision: 0059
Revision ID: 4cd3011ada05
Revises: 3bc28e6d9f90
Create Date: 2016-05-20 10:56:23.169068

"""

# revision identifiers, used by Alembic.
revision = '4cd3011ada05'
down_revision = '3bc28e6d9f90'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.add_column('users', sa.Column('is_disabled', sa.Boolean(), nullable=True))
    op.add_column('users', sa.Column('disabled_at', sa.DateTime(), nullable=True))
    op.add_column('users', sa.Column('last_activity_at', sa.DateTime(), nullable=True))
    op.execute("UPDATE users SET is_disabled=false, last_activity_at = last_login_at")
    op.alter_column('users', 'is_disabled', nullable=False)


def downgrade():
    op.drop_column('users', 'last_activity_at')
    op.drop_column('users', 'is_disabled')
    op.drop_column('users', 'disabled_at')