"""Initial table layout

Revision ID: 2758f36a2fb5
Revises: None
Create Date: 2014-03-11 09:56:35.692538

"""

# revision identifiers, used by Alembic.
revision = '2758f36a2fb5'
down_revision = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('firstname', sa.String(length=80), nullable=True),
    sa.Column('lastname', sa.String(length=80), nullable=True),
    sa.Column('username', sa.String(length=80), nullable=True),
    sa.Column('email', sa.String(length=80), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('poll',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=80), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('slug', sa.String(length=80), nullable=True),
    sa.Column('type', sa.Enum('date', 'normal', name='poll_type'), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('due_date', sa.DateTime(), nullable=True),
    sa.Column('anonymous_allowed', sa.Boolean(), nullable=True),
    sa.Column('public_listing', sa.Boolean(), nullable=True),
    sa.Column('require_login', sa.Boolean(), nullable=True),
    sa.Column('show_results', sa.Enum('summary', 'complete', 'never', 'summary_after_vote', 'complete_after_vote', name='poll_show_results'), nullable=True),
    sa.Column('send_mail', sa.Boolean(), nullable=True),
    sa.Column('one_vote_per_user', sa.Boolean(), nullable=True),
    sa.Column('allow_comments', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('comment',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('text', sa.String(length=80), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('poll_id', sa.Integer(), nullable=True),
    sa.Column('deleted', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['poll_id'], ['poll.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('choice_value',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=80), nullable=True),
    sa.Column('icon', sa.String(length=64), nullable=True),
    sa.Column('color', sa.String(length=6), nullable=True),
    sa.Column('poll_id', sa.Integer(), nullable=True),
    sa.Column('deleted', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['poll_id'], ['poll.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('choice',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('text', sa.String(length=80), nullable=True),
    sa.Column('date', sa.DateTime(), nullable=True),
    sa.Column('poll_id', sa.Integer(), nullable=True),
    sa.Column('deleted', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['poll_id'], ['poll.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('vote',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('poll_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('anonymous', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['poll_id'], ['poll.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('vote_choice',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('comment', sa.String(length=64), nullable=True),
    sa.Column('value_id', sa.Integer(), nullable=True),
    sa.Column('vote_id', sa.Integer(), nullable=True),
    sa.Column('choice_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['choice_id'], ['choice.id'], ),
    sa.ForeignKeyConstraint(['value_id'], ['choice_value.id'], ),
    sa.ForeignKeyConstraint(['vote_id'], ['vote.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('vote_choice')
    op.drop_table('vote')
    op.drop_table('choice')
    op.drop_table('choice_value')
    op.drop_table('comment')
    op.drop_table('poll')
    op.drop_table('user')
    ### end Alembic commands ###
