"""Added accident_year as primary key

Revision ID: 514e03c883e0
Revises: 3070e32fe18
Create Date: 2019-10-19

"""

# revision identifiers, used by Alembic.
revision = '514e03c883e0'
down_revision = '59ed13585934'
branch_labels = None
depends_on = None

from alembic import op


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('involved_accident_id_provider_code_fkey', 'involved', type_='foreignkey')
    op.drop_constraint('vehicles_accident_id_provider_code_fkey', 'vehicles', type_='foreignkey')
    op.drop_constraint('markers_pkey', 'markers', type_='primary')
    op.create_primary_key('markers_pkey', 'markers', ['id', 'provider_code', 'accident_year'])
    op.create_foreign_key('involved_accident_id_fkey', 'involved', 'markers',
                          ['accident_id', 'provider_code', 'accident_year'], ['id', 'provider_code', 'accident_year'],
                          ondelete='CASCADE')
    op.create_foreign_key('vehicles_accident_id_fkey', 'vehicles', 'markers',
                          ['accident_id', 'provider_code', 'accident_year'], ['id', 'provider_code', 'accident_year'],
                          ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('involved_accident_id_provider_code_fkey', 'involved', type_='foreignkey')
    op.drop_constraint('vehicles_accident_id_provider_code_fkey', 'vehicles', type_='foreignkey')
    op.drop_constraint('markers_pkey', 'markers', type_='primary')
    op.create_primary_key('markers_pkey', 'markers', ['id', 'provider_code'])
    op.create_foreign_key('involved_accident_id_fkey', 'involved', 'markers', ['accident_id', 'provider_code', ],
                          ['id', 'provider_code'], ondelete='CASCADE')
    op.create_foreign_key('vehicles_accident_id_fkey', 'vehicles', 'markers', ['accident_id', 'provider_code', ],
                          ['id', 'provider_code'], ondelete='CASCADE')
    # ### end Alembic commands ###

"""Added accident_year as primary key

Revision ID: 514e03c883e0
Revises: 3070e32fe18
Create Date: 2019-10-19

"""

# revision identifiers, used by Alembic.
revision = '514e03c883e0'
down_revision = '59ed13585934'
branch_labels = None
depends_on = None

from alembic import op


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('involved_accident_id_fkey', 'involved', type_='foreignkey')
    op.drop_constraint('involved_accident_id_fkey', 'vehicles', type_='foreignkey')
    op.drop_constraint('markers_pkey', 'markers', type_='primary')
    op.create_primary_key('markers_pkey', 'markers', ['id', 'provider_code', 'accident_year'])
    op.create_foreign_key('involved_accident_id_fkey', 'involved', 'markers',
                          ['accident_id', 'provider_code', 'accident_year'], ['id', 'provider_code', 'accident_year'],
                          ondelete='CASCADE')
    op.create_foreign_key('vehicles_accident_id_fkey', 'vehicles', 'markers',
                          ['accident_id', 'provider_code', 'accident_year'], ['id', 'provider_code', 'accident_year'],
                          ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('involved_accident_id_fkey', 'involved', type_='foreignkey')
    op.drop_constraint('vehicles_accident_id_fkey', 'vehicles', type_='foreignkey')
    op.drop_constraint('markers_pkey', 'markers', type_='primary')
    op.create_primary_key('markers_pkey', 'markers', ['id', 'provider_code'])
    op.create_foreign_key('involved_accident_id_fkey', 'involved', 'markers', ['accident_id', 'provider_code', ],
                          ['id', 'provider_code'], ondelete='CASCADE')
    op.create_foreign_key('vehicles_accident_id_fkey', 'vehicles', 'markers', ['accident_id', 'provider_code', ],
                          ['id', 'provider_code'], ondelete='CASCADE')
    # ### end Alembic commands ###

revert changes to this alembic version