"""create_content_models

Revision ID: 9101b893be5c
Revises: 
Create Date: 2017-02-17 13:37:11.440351

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9101b893be5c'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('content',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('image_path', sa.String(length=200), nullable=True),
    sa.Column('reference_info', sa.JSON(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('content_category',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('content_classification',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('category_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['category_id'], ['content_category.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('content_classification_option',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('classification_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['classification_id'], ['content_classification.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('contents_and_options',
    sa.Column('content_id', sa.Integer(), nullable=True),
    sa.Column('content_classification_option_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['content_classification_option_id'], ['content_classification_option.id'], ),
    sa.ForeignKeyConstraint(['content_id'], ['content.id'], )
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('contents_and_options')
    op.drop_table('content_classification_option')
    op.drop_table('content_classification')
    op.drop_table('content_category')
    op.drop_table('content')
    # ### end Alembic commands ###
