"""Update bounty table for git bounty support

Revision ID: 4871cc24f70a
Revises: 0c8f2d22f112
Create Date: 2021-04-24 00:24:01.957294

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

# revision identifiers, used by Alembic.
revision = '4871cc24f70a'
down_revision = '0c8f2d22f112'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('bounty', sa.Column('git_url', sa.String(), nullable=True))
    op.add_column('bounty', sa.Column('is_git_bounty', sa.Boolean(), nullable=True))
    op.alter_column('bounty', 'description',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.alter_column('bounty', 'external_links',
               existing_type=postgresql.ARRAY(sa.VARCHAR()),
               nullable=True)
    op.create_unique_constraint(op.f('uq_bounty_git_url'), 'bounty', ['git_url'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(op.f('uq_bounty_git_url'), 'bounty', type_='unique')
    op.alter_column('bounty', 'external_links',
               existing_type=postgresql.ARRAY(sa.VARCHAR()),
               nullable=False)
    op.alter_column('bounty', 'description',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.drop_column('bounty', 'is_git_bounty')
    op.drop_column('bounty', 'git_url')
    # ### end Alembic commands ###
