"""Initial migration

Revision ID: 803a85e63506
Revises: 
Create Date: 2021-01-11 15:19:33.956987

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

# revision identifiers, used by Alembic.
revision = '803a85e63506'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('bounty', 'currency_code',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.alter_column('bounty', 'external_links',
               existing_type=postgresql.ARRAY(sa.TEXT()),
               nullable=False)
    op.drop_constraint('fk_category_id', 'bounty_category', type_='foreignkey')
    op.drop_constraint('fk_bounty_id', 'bounty_category', type_='foreignkey')
    op.create_foreign_key(None, 'bounty_category', 'category', ['category_id'], ['category_id'], ondelete='CASCADE')
    op.create_foreign_key(None, 'bounty_category', 'bounty', ['bounty_id'], ['bounty_id'], ondelete='CASCADE')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'bounty_category', type_='foreignkey')
    op.drop_constraint(None, 'bounty_category', type_='foreignkey')
    op.create_foreign_key('fk_bounty_id', 'bounty_category', 'bounty', ['bounty_id'], ['bounty_id'])
    op.create_foreign_key('fk_category_id', 'bounty_category', 'category', ['category_id'], ['category_id'])
    op.alter_column('bounty', 'external_links',
               existing_type=postgresql.ARRAY(sa.TEXT()),
               nullable=True)
    op.alter_column('bounty', 'currency_code',
               existing_type=sa.VARCHAR(),
               nullable=False)
    # ### end Alembic commands ###
