<gh_stars>1-10
"""better naming for uuids

Revision ID: 628398d591ae
Revises: <PASSWORD>
Create Date: 2020-03-03 19:23:31.440009

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

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('deliverable', sa.Column('task_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.drop_constraint('deliverable_task_id_fkey', 'deliverable', type_='foreignkey')
    op.create_foreign_key(None, 'deliverable', 'task', ['task_uuid'], ['uuid'])
    op.drop_column('deliverable', 'task_id')
    op.add_column('note', sa.Column('deliverable_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.add_column('note', sa.Column('session_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.add_column('note', sa.Column('task_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.add_column('note', sa.Column('user_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.add_column('note', sa.Column('vehicle_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.drop_constraint('note_task_id_fkey', 'note', type_='foreignkey')
    op.drop_constraint('note_deliverable_id_fkey', 'note', type_='foreignkey')
    op.drop_constraint('note_session_id_fkey', 'note', type_='foreignkey')
    op.drop_constraint('note_vehicle_id_fkey', 'note', type_='foreignkey')
    op.drop_constraint('note_user_id_fkey', 'note', type_='foreignkey')
    op.create_foreign_key(None, 'note', 'vehicle', ['vehicle_uuid'], ['uuid'])
    op.create_foreign_key(None, 'note', 'session', ['session_uuid'], ['uuid'])
    op.create_foreign_key(None, 'note', 'task', ['task_uuid'], ['uuid'])
    op.create_foreign_key(None, 'note', 'user', ['user_uuid'], ['uuid'])
    op.create_foreign_key(None, 'note', 'deliverable', ['deliverable_uuid'], ['uuid'])
    op.drop_column('note', 'vehicle_id')
    op.drop_column('note', 'session_id')
    op.drop_column('note', 'user_id')
    op.drop_column('note', 'deliverable_id')
    op.drop_column('note', 'task_id')
    op.add_column('session', sa.Column('user_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.drop_constraint('session_user_id_fkey', 'session', type_='foreignkey')
    op.create_foreign_key(None, 'session', 'user', ['user_uuid'], ['uuid'])
    op.drop_column('session', 'user_id')
    op.add_column('task', sa.Column('session_uuid', postgresql.UUID(as_uuid=True), nullable=True))
    op.drop_constraint('task_session_id_fkey', 'task', type_='foreignkey')
    op.create_foreign_key(None, 'task', 'session', ['session_uuid'], ['uuid'])
    op.drop_column('task', 'session_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('task', sa.Column('session_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'task', type_='foreignkey')
    op.create_foreign_key('task_session_id_fkey', 'task', 'session', ['session_id'], ['uuid'])
    op.drop_column('task', 'session_uuid')
    op.add_column('session', sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'session', type_='foreignkey')
    op.create_foreign_key('session_user_id_fkey', 'session', 'user', ['user_id'], ['uuid'])
    op.drop_column('session', 'user_uuid')
    op.add_column('note', sa.Column('task_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('note', sa.Column('deliverable_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('note', sa.Column('user_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('note', sa.Column('session_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.add_column('note', sa.Column('vehicle_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'note', type_='foreignkey')
    op.drop_constraint(None, 'note', type_='foreignkey')
    op.drop_constraint(None, 'note', type_='foreignkey')
    op.drop_constraint(None, 'note', type_='foreignkey')
    op.drop_constraint(None, 'note', type_='foreignkey')
    op.create_foreign_key('note_user_id_fkey', 'note', 'user', ['user_id'], ['uuid'])
    op.create_foreign_key('note_vehicle_id_fkey', 'note', 'vehicle', ['vehicle_id'], ['uuid'])
    op.create_foreign_key('note_session_id_fkey', 'note', 'session', ['session_id'], ['uuid'])
    op.create_foreign_key('note_deliverable_id_fkey', 'note', 'deliverable', ['deliverable_id'], ['uuid'])
    op.create_foreign_key('note_task_id_fkey', 'note', 'task', ['task_id'], ['uuid'])
    op.drop_column('note', 'vehicle_uuid')
    op.drop_column('note', 'user_uuid')
    op.drop_column('note', 'task_uuid')
    op.drop_column('note', 'session_uuid')
    op.drop_column('note', 'deliverable_uuid')
    op.add_column('deliverable', sa.Column('task_id', postgresql.UUID(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'deliverable', type_='foreignkey')
    op.create_foreign_key('deliverable_task_id_fkey', 'deliverable', 'task', ['task_id'], ['uuid'])
    op.drop_column('deliverable', 'task_uuid')
    # ### end Alembic commands ###
