"""alter db

Revision ID: d9b134d71b1f
Revises: 309c8478ded6
Create Date: 2016-09-04 19:54:45.818910

"""

# revision identifiers, used by Alembic.
revision = 'd9b134d71b1f'
down_revision = '309c8478ded6'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('campaign', sa.Column('mail_id', sa.Integer(), nullable=True))
    op.add_column('campaign', sa.Column('person_category_id', sa.Integer(), nullable=True))
    op.create_foreign_key('fk_person_category_id_campaign', 'campaign', 'person_category', ['person_category_id'], ['id'], onupdate='cascade', ondelete='restrict')
    op.create_foreign_key('fk_mail_id_campaign', 'campaign', 'mail', ['mail_id'], ['id'], onupdate='cascade', ondelete='restrict')
    op.drop_column('campaign', 'html_content')
    op.drop_column('campaign', 'subject')
    op.drop_column('campaign', 'plain_content')
    op.add_column('mail', sa.Column('subject', sa.String(length=128), nullable=False))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('mail', 'subject')
    op.add_column('campaign', sa.Column('plain_content', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('campaign', sa.Column('subject', sa.VARCHAR(length=128), autoincrement=False, nullable=False))
    op.add_column('campaign', sa.Column('html_content', sa.TEXT(), autoincrement=False, nullable=True))
    op.drop_constraint('fk_mail_id_campaign', 'campaign', type_='foreignkey')
    op.drop_constraint('fk_person_category_id_campaign', 'campaign', type_='foreignkey')
    op.drop_column('campaign', 'person_category_id')
    op.drop_column('campaign', 'mail_id')
    ### end Alembic commands ###
