"""add tables for marketing campaigns

Revision ID: 0292af3cd6ea
Revises: 95bba96964e3
Create Date: 2017-02-01 20:41:05.374642

"""

# revision identifiers, used by Alembic.
revision = '0292af3cd6ea'
down_revision = '95bba96964e3'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.schema import Sequence, CreateSequence


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('marketing_campaigns',
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('name', sa.Text(), nullable=True),
    sa.Column('start_date', sa.DateTime(), nullable=True),
    sa.Column('end_date', sa.DateTime(), nullable=True),
    sa.Column('token', sa.Text(), nullable=True),
    sa.Column('notes', sa.Text(), nullable=True),
    sa.Column('created_by_user_id', sa.BigInteger(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.execute(CreateSequence(Sequence('marketing_campaign_id_seq')))
    op.create_table('marketing_campaign_users',
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('user_id', sa.BigInteger(), nullable=True),
    sa.Column('marketing_campaign_id', sa.BigInteger(), nullable=True),
    sa.ForeignKeyConstraint(['marketing_campaign_id'], ['marketing_campaigns.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.execute(CreateSequence(Sequence('marketing_campaign_user_id_seq')))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('marketing_campaign_users')
    op.drop_table('marketing_campaigns')
    ### end Alembic commands ###
