"""empty message

Revision ID: 5af1c669a75d
Revises: 
Create Date: 2019-03-08 15:28:21.203771

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '5af1c669a75d'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('t_user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('last_seen', sa.DateTime(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('t_question',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('content', sa.Text(length=1024), nullable=True),
    sa.Column('answers_count', sa.Integer(), nullable=True),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['t_user.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('t_answer',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('content', sa.Text(length=1024), nullable=True),
    sa.Column('comments_count', sa.Integer(), nullable=True),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('question_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['t_user.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['question_id'], ['t_question.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('t_comment',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('content', sa.Text(length=1024), nullable=True),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('answer_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['answer_id'], ['t_answer.id'], ),
    sa.ForeignKeyConstraint(['author_id'], ['t_user.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('t_comment')
    op.drop_table('t_answer')
    op.drop_table('t_question')
    op.drop_table('t_user')
    # ### end Alembic commands ###
