<reponame>neil-rutherford/icyfire-website
"""Sales hierarchy depracation

Revision ID: 4e95ea571bce
Revises: 
Create Date: 2020-09-22 10:38:58.695475

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4e95ea571bce'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('partner',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('first_name', sa.String(length=50), nullable=True),
    sa.Column('last_name', sa.String(length=50), nullable=True),
    sa.Column('phone_number', sa.String(length=15), nullable=True),
    sa.Column('email', sa.String(length=100), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('lead',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('ip_address', sa.String(length=15), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('partner_id', sa.Integer(), nullable=True),
    sa.Column('is_contacted', sa.Boolean(), nullable=True),
    sa.Column('first_name', sa.String(length=50), nullable=True),
    sa.Column('last_name', sa.String(length=50), nullable=True),
    sa.Column('company_name', sa.String(length=100), nullable=True),
    sa.Column('job_title', sa.String(length=100), nullable=True),
    sa.Column('number_of_employees', sa.Integer(), nullable=True),
    sa.Column('time_zone', sa.Integer(), nullable=True),
    sa.Column('phone_number', sa.String(length=15), nullable=True),
    sa.Column('email', sa.String(length=100), nullable=True),
    sa.Column('contact_preference', sa.Integer(), nullable=True),
    sa.Column('time_preference', sa.Integer(), nullable=True),
    sa.Column('email_opt_in', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['partner_id'], ['partner.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_lead_timestamp'), 'lead', ['timestamp'], unique=False)
    op.create_table('sale',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('partner_id', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('client_name', sa.String(length=100), nullable=True),
    sa.Column('client_street_address', sa.String(length=100), nullable=True),
    sa.Column('client_city', sa.String(length=60), nullable=True),
    sa.Column('client_state', sa.String(length=50), nullable=True),
    sa.Column('client_country', sa.String(length=55), nullable=True),
    sa.Column('client_zip', sa.String(length=15), nullable=True),
    sa.Column('client_phone_country', sa.Integer(), nullable=True),
    sa.Column('client_phone_number', sa.String(length=15), nullable=True),
    sa.Column('client_email', sa.String(length=254), nullable=True),
    sa.Column('product_id', sa.String(length=20), nullable=True),
    sa.Column('unit_price', sa.Float(), nullable=True),
    sa.Column('quantity', sa.Integer(), nullable=True),
    sa.Column('subtotal', sa.Float(), nullable=True),
    sa.Column('sales_tax', sa.Float(), nullable=True),
    sa.Column('total', sa.Float(), nullable=True),
    sa.Column('receipt_url', sa.String(length=300), nullable=True),
    sa.Column('payment_reference', sa.String(length=100), nullable=True),
    sa.ForeignKeyConstraint(['partner_id'], ['partner.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_sale_timestamp'), 'sale', ['timestamp'], unique=False)
    op.create_table('domain',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_name', sa.String(length=120), nullable=True),
    sa.Column('sale_id', sa.Integer(), nullable=True),
    sa.Column('activation_code', sa.String(length=300), nullable=True),
    sa.Column('expires_on', sa.DateTime(), nullable=True),
    sa.Column('stripe_customer_id', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['sale_id'], ['sale.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('activation_code'),
    sa.UniqueConstraint('stripe_customer_id')
    )
    op.create_index(op.f('ix_domain_domain_name'), 'domain', ['domain_name'], unique=True)
    op.create_index(op.f('ix_domain_expires_on'), 'domain', ['expires_on'], unique=False)
    op.create_table('facebook_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('page_id', sa.String(length=50), nullable=True),
    sa.Column('access_token', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('reddit_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('client_id', sa.String(length=300), nullable=True),
    sa.Column('client_secret', sa.String(length=300), nullable=True),
    sa.Column('user_agent', sa.String(length=300), nullable=True),
    sa.Column('username', sa.String(length=300), nullable=True),
    sa.Column('password', sa.String(length=300), nullable=True),
    sa.Column('target_subreddit', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tumblr_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('consumer_key', sa.String(length=300), nullable=True),
    sa.Column('consumer_secret', sa.String(length=300), nullable=True),
    sa.Column('oauth_token', sa.String(length=300), nullable=True),
    sa.Column('oauth_secret', sa.String(length=300), nullable=True),
    sa.Column('blog_name', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('twitter_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('consumer_key', sa.String(length=300), nullable=True),
    sa.Column('consumer_secret', sa.String(length=300), nullable=True),
    sa.Column('access_token_key', sa.String(length=300), nullable=True),
    sa.Column('access_token_secret', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('partner_id', sa.Integer(), nullable=True),
    sa.Column('email', sa.String(length=254), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('post_count', sa.Integer(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.Column('is_create', sa.Boolean(), nullable=True),
    sa.Column('is_read', sa.Boolean(), nullable=True),
    sa.Column('is_update', sa.Boolean(), nullable=True),
    sa.Column('is_delete', sa.Boolean(), nullable=True),
    sa.Column('is_verified', sa.Boolean(), nullable=True),
    sa.Column('email_opt_in', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['partner_id'], ['partner.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_table('facebook_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.Column('tags', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['facebook_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_facebook_post_timestamp'), 'facebook_post', ['timestamp'], unique=False)
    op.create_table('reddit_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('title', sa.String(length=300), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['reddit_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_reddit_post_timestamp'), 'reddit_post', ['timestamp'], unique=False)
    op.create_table('sentry',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('ip_address', sa.String(length=15), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('endpoint', sa.String(length=254), nullable=True),
    sa.Column('status_code', sa.Integer(), nullable=True),
    sa.Column('status_message', sa.String(length=100), nullable=True),
    sa.Column('flag', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_sentry_timestamp'), 'sentry', ['timestamp'], unique=False)
    op.create_table('time_slot',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('facebook_cred_id', sa.Integer(), nullable=True),
    sa.Column('twitter_cred_id', sa.Integer(), nullable=True),
    sa.Column('tumblr_cred_id', sa.Integer(), nullable=True),
    sa.Column('reddit_cred_id', sa.Integer(), nullable=True),
    sa.Column('server_id', sa.Integer(), nullable=True),
    sa.Column('day_of_week', sa.Integer(), nullable=True),
    sa.Column('time', sa.String(length=5), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['facebook_cred_id'], ['facebook_cred.id'], ),
    sa.ForeignKeyConstraint(['reddit_cred_id'], ['reddit_cred.id'], ),
    sa.ForeignKeyConstraint(['tumblr_cred_id'], ['tumblr_cred.id'], ),
    sa.ForeignKeyConstraint(['twitter_cred_id'], ['twitter_cred.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tumblr_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('title', sa.String(length=300), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('tags', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['tumblr_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_tumblr_post_timestamp'), 'tumblr_post', ['timestamp'], unique=False)
    op.create_table('twitter_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('body', sa.String(length=300), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.Column('tags', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['twitter_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_twitter_post_timestamp'), 'twitter_post', ['timestamp'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_twitter_post_timestamp'), table_name='twitter_post')
    op.drop_table('twitter_post')
    op.drop_index(op.f('ix_tumblr_post_timestamp'), table_name='tumblr_post')
    op.drop_table('tumblr_post')
    op.drop_table('time_slot')
    op.drop_index(op.f('ix_sentry_timestamp'), table_name='sentry')
    op.drop_table('sentry')
    op.drop_index(op.f('ix_reddit_post_timestamp'), table_name='reddit_post')
    op.drop_table('reddit_post')
    op.drop_index(op.f('ix_facebook_post_timestamp'), table_name='facebook_post')
    op.drop_table('facebook_post')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
    op.drop_table('twitter_cred')
    op.drop_table('tumblr_cred')
    op.drop_table('reddit_cred')
    op.drop_table('facebook_cred')
    op.drop_index(op.f('ix_domain_expires_on'), table_name='domain')
    op.drop_index(op.f('ix_domain_domain_name'), table_name='domain')
    op.drop_table('domain')
    op.drop_index(op.f('ix_sale_timestamp'), table_name='sale')
    op.drop_table('sale')
    op.drop_index(op.f('ix_lead_timestamp'), table_name='lead')
    op.drop_table('lead')
    op.drop_table('partner')
    # ### end Alembic commands ###

"""Sales hierarchy depracation

Revision ID: 4e95ea571bce
Revises: 
Create Date: 2020-09-22 10:38:58.695475

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4e95ea571bce'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('partner',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('first_name', sa.String(length=50), nullable=True),
    sa.Column('last_name', sa.String(length=50), nullable=True),
    sa.Column('phone_number', sa.String(length=15), nullable=True),
    sa.Column('email', sa.String(length=100), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('lead',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('ip_address', sa.String(length=15), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('partner_id', sa.Integer(), nullable=True),
    sa.Column('is_contacted', sa.Boolean(), nullable=True),
    sa.Column('first_name', sa.String(length=50), nullable=True),
    sa.Column('last_name', sa.String(length=50), nullable=True),
    sa.Column('company_name', sa.String(length=100), nullable=True),
    sa.Column('job_title', sa.String(length=100), nullable=True),
    sa.Column('number_of_employees', sa.Integer(), nullable=True),
    sa.Column('time_zone', sa.Integer(), nullable=True),
    sa.Column('phone_number', sa.String(length=15), nullable=True),
    sa.Column('email', sa.String(length=100), nullable=True),
    sa.Column('contact_preference', sa.Integer(), nullable=True),
    sa.Column('time_preference', sa.Integer(), nullable=True),
    sa.Column('email_opt_in', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['partner_id'], ['partner.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_lead_timestamp'), 'lead', ['timestamp'], unique=False)
    op.create_table('sale',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('partner_id', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('client_name', sa.String(length=100), nullable=True),
    sa.Column('client_street_address', sa.String(length=100), nullable=True),
    sa.Column('client_city', sa.String(length=60), nullable=True),
    sa.Column('client_state', sa.String(length=50), nullable=True),
    sa.Column('client_country', sa.String(length=55), nullable=True),
    sa.Column('client_zip', sa.String(length=15), nullable=True),
    sa.Column('client_phone_country', sa.Integer(), nullable=True),
    sa.Column('client_phone_number', sa.String(length=15), nullable=True),
    sa.Column('client_email', sa.String(length=254), nullable=True),
    sa.Column('product_id', sa.String(length=20), nullable=True),
    sa.Column('unit_price', sa.Float(), nullable=True),
    sa.Column('quantity', sa.Integer(), nullable=True),
    sa.Column('subtotal', sa.Float(), nullable=True),
    sa.Column('sales_tax', sa.Float(), nullable=True),
    sa.Column('total', sa.Float(), nullable=True),
    sa.Column('receipt_url', sa.String(length=300), nullable=True),
    sa.Column('payment_reference', sa.String(length=100), nullable=True),
    sa.ForeignKeyConstraint(['partner_id'], ['partner.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_sale_timestamp'), 'sale', ['timestamp'], unique=False)
    op.create_table('domain',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_name', sa.String(length=120), nullable=True),
    sa.Column('sale_id', sa.Integer(), nullable=True),
    sa.Column('activation_code', sa.String(length=300), nullable=True),
    sa.Column('expires_on', sa.DateTime(), nullable=True),
    sa.Column('stripe_customer_id', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['sale_id'], ['sale.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('activation_code'),
    sa.UniqueConstraint('stripe_customer_id')
    )
    op.create_index(op.f('ix_domain_domain_name'), 'domain', ['domain_name'], unique=True)
    op.create_index(op.f('ix_domain_expires_on'), 'domain', ['expires_on'], unique=False)
    op.create_table('facebook_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('page_id', sa.String(length=50), nullable=True),
    sa.Column('access_token', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('reddit_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('client_id', sa.String(length=300), nullable=True),
    sa.Column('client_secret', sa.String(length=300), nullable=True),
    sa.Column('user_agent', sa.String(length=300), nullable=True),
    sa.Column('username', sa.String(length=300), nullable=True),
    sa.Column('password', sa.String(length=300), nullable=True),
    sa.Column('target_subreddit', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tumblr_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('consumer_key', sa.String(length=300), nullable=True),
    sa.Column('consumer_secret', sa.String(length=300), nullable=True),
    sa.Column('oauth_token', sa.String(length=300), nullable=True),
    sa.Column('oauth_secret', sa.String(length=300), nullable=True),
    sa.Column('blog_name', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('twitter_cred',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('alias', sa.String(length=50), nullable=True),
    sa.Column('consumer_key', sa.String(length=300), nullable=True),
    sa.Column('consumer_secret', sa.String(length=300), nullable=True),
    sa.Column('access_token_key', sa.String(length=300), nullable=True),
    sa.Column('access_token_secret', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('partner_id', sa.Integer(), nullable=True),
    sa.Column('email', sa.String(length=254), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('post_count', sa.Integer(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.Column('is_create', sa.Boolean(), nullable=True),
    sa.Column('is_read', sa.Boolean(), nullable=True),
    sa.Column('is_update', sa.Boolean(), nullable=True),
    sa.Column('is_delete', sa.Boolean(), nullable=True),
    sa.Column('is_verified', sa.Boolean(), nullable=True),
    sa.Column('email_opt_in', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['partner_id'], ['partner.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_table('facebook_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.Column('tags', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['facebook_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_facebook_post_timestamp'), 'facebook_post', ['timestamp'], unique=False)
    op.create_table('reddit_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('title', sa.String(length=300), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['reddit_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_reddit_post_timestamp'), 'reddit_post', ['timestamp'], unique=False)
    op.create_table('sentry',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('ip_address', sa.String(length=15), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('endpoint', sa.String(length=254), nullable=True),
    sa.Column('status_code', sa.Integer(), nullable=True),
    sa.Column('status_message', sa.String(length=100), nullable=True),
    sa.Column('flag', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_sentry_timestamp'), 'sentry', ['timestamp'], unique=False)
    op.create_table('time_slot',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('facebook_cred_id', sa.Integer(), nullable=True),
    sa.Column('twitter_cred_id', sa.Integer(), nullable=True),
    sa.Column('tumblr_cred_id', sa.Integer(), nullable=True),
    sa.Column('reddit_cred_id', sa.Integer(), nullable=True),
    sa.Column('server_id', sa.Integer(), nullable=True),
    sa.Column('day_of_week', sa.Integer(), nullable=True),
    sa.Column('time', sa.String(length=5), nullable=True),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['facebook_cred_id'], ['facebook_cred.id'], ),
    sa.ForeignKeyConstraint(['reddit_cred_id'], ['reddit_cred.id'], ),
    sa.ForeignKeyConstraint(['tumblr_cred_id'], ['tumblr_cred.id'], ),
    sa.ForeignKeyConstraint(['twitter_cred_id'], ['twitter_cred.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tumblr_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('title', sa.String(length=300), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('tags', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['tumblr_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_tumblr_post_timestamp'), 'tumblr_post', ['timestamp'], unique=False)
    op.create_table('twitter_post',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('domain_id', sa.Integer(), nullable=True),
    sa.Column('cred_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_type', sa.Integer(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('body', sa.String(length=300), nullable=True),
    sa.Column('caption', sa.String(length=300), nullable=True),
    sa.Column('link_url', sa.String(length=300), nullable=True),
    sa.Column('multimedia_url', sa.String(length=300), nullable=True),
    sa.Column('tags', sa.String(length=300), nullable=True),
    sa.ForeignKeyConstraint(['cred_id'], ['twitter_cred.id'], ),
    sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_twitter_post_timestamp'), 'twitter_post', ['timestamp'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_twitter_post_timestamp'), table_name='twitter_post')
    op.drop_table('twitter_post')
    op.drop_index(op.f('ix_tumblr_post_timestamp'), table_name='tumblr_post')
    op.drop_table('tumblr_post')
    op.drop_table('time_slot')
    op.drop_index(op.f('ix_sentry_timestamp'), table_name='sentry')
    op.drop_table('sentry')
    op.drop_index(op.f('ix_reddit_post_timestamp'), table_name='reddit_post')
    op.drop_table('reddit_post')
    op.drop_index(op.f('ix_facebook_post_timestamp'), table_name='facebook_post')
    op.drop_table('facebook_post')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
    op.drop_table('twitter_cred')
    op.drop_table('tumblr_cred')
    op.drop_table('reddit_cred')
    op.drop_table('facebook_cred')
    op.drop_index(op.f('ix_domain_expires_on'), table_name='domain')
    op.drop_index(op.f('ix_domain_domain_name'), table_name='domain')
    op.drop_table('domain')
    op.drop_index(op.f('ix_sale_timestamp'), table_name='sale')
    op.drop_table('sale')
    op.drop_index(op.f('ix_lead_timestamp'), table_name='lead')
    op.drop_table('lead')
    op.drop_table('partner')
    # ### end Alembic commands ###
Sales hierarchy depracation  Revision ID: 4e95ea571bce Revises:  Create Date: 2020-09-22 10:38:58.695475 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###