"""Link emails together with ConnectionEvents

Revision ID: 49f54a337616
Revises: 5221f62bc632
Create Date: 2015-10-02 18:49:39.712951

"""

# revision identifiers, used by Alembic.
revision = '49f54a337616'
down_revision = '5221f62bc632'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('email', sa.Column('connection_event_id', sa.Integer(), nullable=False))
    op.create_foreign_key(None, 'email', 'events', ['connection_event_id'], ['id'])
    op.add_column('events', sa.Column('total_connections', sa.Integer(), nullable=True))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('events', 'total_connections')
    op.drop_constraint(None, 'email', type_='foreignkey')
    op.drop_column('email', 'connection_event_id')
    ### end Alembic commands ###
