"""Renamed password_ticket user column and removed created_on.

Revision ID: 58ec866f9f20
Revises: e28438a52376
Create Date: 2017-10-16 21:41:17.075730

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

# revision identifiers, used by Alembic.
revision = '58ec866f9f20'
down_revision = 'e28438a52376'


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###

    op.drop_constraint('password_ticket_ibfk_1', 'password_ticket',
                       type_='foreignkey')

    op.alter_column('password_ticket', 'user', new_column_name='user_id',
                    existing_type=sa.Integer)

    op.create_foreign_key(op.f('fk_password_ticket_user_id_user'),
                          'password_ticket', 'user', ['user_id'], ['id'])

    op.drop_column('password_ticket', 'created_on')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###

    op.add_column('password_ticket', sa.Column('created_on', mysql.DATETIME(),
                                               nullable=False))

    op.drop_constraint(op.f('fk_password_ticket_user_id_user'),
                       'password_ticket', type_='foreignkey')

    op.alter_column('password_ticket', 'user_id', new_column_name='user',
                    existing_type=sa.Integer())

    op.create_foreign_key('password_ticket_ibfk_1', 'password_ticket', 'user',
                          ['user'], ['id'])

    # ### end Alembic commands ###
