<reponame>poikilos/pygameweb<gh_stars>10-100
"""Comment models.

Revision ID: 8d334297f83a
Revises: <PASSWORD>
Create Date: 2017-03-06 16:19:16.913311

"""

# revision identifiers, used by Alembic.
revision = '8d334297f83a'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comment_author',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('email', sa.String(length=80), nullable=True),
    sa.Column('link', sa.String(length=80), nullable=True),
    sa.Column('username', sa.String(length=80), nullable=True),
    sa.Column('is_anonymous', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'email', 'is_anonymous', name='_name_email_is_anonymous_uc')
    )
    op.create_table('comment_category',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('forum', sa.String(length=80), nullable=True),
    sa.Column('title', sa.String(length=80), nullable=True),
    sa.Column('order', sa.BigInteger(), nullable=True),
    sa.Column('is_default', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('comment_thread',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('id_text', sa.String(length=255), nullable=True),
    sa.Column('forum', sa.String(length=255), nullable=True),
    sa.Column('link', sa.String(length=255), nullable=True),
    sa.Column('title', sa.String(length=255), nullable=True),
    sa.Column('ip_address', sa.String(length=40), nullable=True),
    sa.Column('author_id', sa.BigInteger(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('is_closed', sa.Boolean(), nullable=True),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['comment_author.id'], name='comment_thread_author_id_fkey'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('comment_post',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('parent_id', sa.BigInteger(), nullable=True),
    sa.Column('thread_id', sa.BigInteger(), nullable=False),
    sa.Column('message', sa.Text(), nullable=True),
    sa.Column('ip_address', sa.String(length=80), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('is_deleted', sa.Boolean(), nullable=True),
    sa.Column('is_approved', sa.Boolean(), nullable=True),
    sa.Column('is_spam', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.BigInteger(), nullable=False),
    sa.ForeignKeyConstraint(['author_id'], ['comment_author.id'], name='comment_post_author_id_fkey'),
    sa.ForeignKeyConstraint(['parent_id'], ['comment_post.id'], name='comment_post_parent_id_fkey'),
    sa.ForeignKeyConstraint(['thread_id'], ['comment_thread.id'], name='comment_post_thread_id_fkey'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('comment_post')
    op.drop_table('comment_thread')
    op.drop_table('comment_category')
    op.drop_table('comment_author')
    # ### end Alembic commands ###
