"""Add extra attendees to CustomForm.

Revision ID: 825dad56a2c3
Revises: 7525fd3b67d5
Create Date: 2018-01-13 16:19:50.651900

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '825dad56a2c3'
down_revision = '009352d11348'


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('custom_form', sa.Column('introductions', sa.Integer(),
                                           nullable=True))
    op.add_column('custom_form_result', sa.Column('introductions',
                                                  sa.Integer(), nullable=True))
    # ### end Alembic commands ###
    connection = op.get_bind()

    connection.execute("""
        UPDATE custom_form_result
           SET introductions = 0
         WHERE introductions is NULL
    """)


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('custom_form_result', 'introductions')
    op.drop_column('custom_form', 'introductions')
    # ### end Alembic commands ###
