"""add ondelete to foreign keys to projects_users

Revision ID: 28e55086b76c
Revises: 9aaefe492ae9
Create Date: 2019-03-13 12:33:09.522274

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '28e55086b76c'
down_revision = '9aaefe492ae9'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('projects_users_user_id_fkey', 'projects_users', type_='foreignkey')
    op.drop_constraint('projects_users_project_id_fkey', 'projects_users', type_='foreignkey')
    op.create_foreign_key(None, 'projects_users', 'projects', ['project_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'projects_users', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'projects_users', type_='foreignkey')
    op.drop_constraint(None, 'projects_users', type_='foreignkey')
    op.create_foreign_key('projects_users_project_id_fkey', 'projects_users', 'projects', ['project_id'], ['id'])
    op.create_foreign_key('projects_users_user_id_fkey', 'projects_users', 'users', ['user_id'], ['id'])
    # ### end Alembic commands ###
