<reponame>nexocodecom/nisse.io
"""clean_up_schema

Revision ID: e86c2eef044c
Revises: <PASSWORD>
Create Date: 2019-12-12 14:36:07.141069

"""
from alembic import op

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(op.f('ix_time_entries_project_id'), 'time_entries', ['project_id'], unique=False)
    op.create_index(op.f('ix_time_entries_user_id'), 'time_entries', ['user_id'], unique=False)
    op.create_foreign_key(None, 'time_entries', 'users', ['user_id'], ['user_id'])
    op.create_foreign_key(None, 'time_entries', 'projects', ['project_id'], ['project_id'])
    op.create_index(op.f('ix_tokens_client_id'), 'tokens', ['client_id'], unique=True)
    op.create_index(op.f('ix_tokens_refresh_token'), 'tokens', ['refresh_token'], unique=True)
    op.drop_constraint('tokens_client_id_key', 'tokens', type_='unique')
    op.create_foreign_key(None, 'user_projects', 'users', ['user_id'], ['user_id'])
    op.create_foreign_key(None, 'user_projects', 'projects', ['project_id'], ['project_id'])
    op.create_index(op.f('ix_users_role_id'), 'users', ['role_id'], unique=False)
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    op.create_foreign_key(None, 'users', 'user_roles', ['role_id'], ['user_role_id'])
    op.drop_constraint('tokens_refresh_token_key', 'tokens', type_='unique')
    op.drop_constraint('users_username_key', 'users', type_='unique')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('users_username_key', 'users', ['username'])
    op.create_unique_constraint('tokens_refresh_token_key', 'tokens', ['refresh_token'])
    op.drop_constraint(None, 'users', type_='foreignkey')
    op.drop_index(op.f('ix_users_username'), table_name='users')
    op.drop_index(op.f('ix_users_role_id'), table_name='users')
    op.drop_constraint(None, 'user_projects', type_='foreignkey')
    op.drop_constraint(None, 'user_projects', type_='foreignkey')
    op.create_unique_constraint('tokens_client_id_key', 'tokens', ['client_id'])
    op.drop_index(op.f('ix_tokens_refresh_token'), table_name='tokens')
    op.drop_index(op.f('ix_tokens_client_id'), table_name='tokens')
    op.drop_constraint(None, 'time_entries', type_='foreignkey')
    op.drop_constraint(None, 'time_entries', type_='foreignkey')
    op.drop_index(op.f('ix_time_entries_user_id'), table_name='time_entries')
    op.drop_index(op.f('ix_time_entries_project_id'), table_name='time_entries')
    # ### end Alembic commands ###

"""clean_up_schema

Revision ID: e86c2eef044c
Revises: <PASSWORD>
Create Date: 2019-12-12 14:36:07.141069

"""
from alembic import op

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(op.f('ix_time_entries_project_id'), 'time_entries', ['project_id'], unique=False)
    op.create_index(op.f('ix_time_entries_user_id'), 'time_entries', ['user_id'], unique=False)
    op.create_foreign_key(None, 'time_entries', 'users', ['user_id'], ['user_id'])
    op.create_foreign_key(None, 'time_entries', 'projects', ['project_id'], ['project_id'])
    op.create_index(op.f('ix_tokens_client_id'), 'tokens', ['client_id'], unique=True)
    op.create_index(op.f('ix_tokens_refresh_token'), 'tokens', ['refresh_token'], unique=True)
    op.drop_constraint('tokens_client_id_key', 'tokens', type_='unique')
    op.create_foreign_key(None, 'user_projects', 'users', ['user_id'], ['user_id'])
    op.create_foreign_key(None, 'user_projects', 'projects', ['project_id'], ['project_id'])
    op.create_index(op.f('ix_users_role_id'), 'users', ['role_id'], unique=False)
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    op.create_foreign_key(None, 'users', 'user_roles', ['role_id'], ['user_role_id'])
    op.drop_constraint('tokens_refresh_token_key', 'tokens', type_='unique')
    op.drop_constraint('users_username_key', 'users', type_='unique')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('users_username_key', 'users', ['username'])
    op.create_unique_constraint('tokens_refresh_token_key', 'tokens', ['refresh_token'])
    op.drop_constraint(None, 'users', type_='foreignkey')
    op.drop_index(op.f('ix_users_username'), table_name='users')
    op.drop_index(op.f('ix_users_role_id'), table_name='users')
    op.drop_constraint(None, 'user_projects', type_='foreignkey')
    op.drop_constraint(None, 'user_projects', type_='foreignkey')
    op.create_unique_constraint('tokens_client_id_key', 'tokens', ['client_id'])
    op.drop_index(op.f('ix_tokens_refresh_token'), table_name='tokens')
    op.drop_index(op.f('ix_tokens_client_id'), table_name='tokens')
    op.drop_constraint(None, 'time_entries', type_='foreignkey')
    op.drop_constraint(None, 'time_entries', type_='foreignkey')
    op.drop_index(op.f('ix_time_entries_user_id'), table_name='time_entries')
    op.drop_index(op.f('ix_time_entries_project_id'), table_name='time_entries')
    # ### end Alembic commands ###
clean_up_schema  Revision ID: e86c2eef044c Revises: <PASSWORD> Create Date: 2019-12-12 14:36:07.141069 # 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 ###