"""initial

Revision ID: c3fd0dde53c0
Revises: 
Create Date: 2019-04-30 23:07:52.412908

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=False),
    sa.Column('email', sa.String(length=128), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=False),
    sa.Column('date_registered', sa.DateTime(), nullable=False),
    sa.Column('is_admin', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_date_registered'), 'user', ['date_registered'], unique=False)
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('vote',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('poll',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=False),
    sa.Column('description', sa.String(length=256), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=False),
    sa.Column('creator_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['creator_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_poll_date_created'), 'poll', ['date_created'], unique=False)
    op.create_index(op.f('ix_poll_name'), 'poll', ['name'], unique=False)
    op.create_table('recipe',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=False),
    sa.Column('description', sa.String(length=256), nullable=True),
    sa.Column('date_added', sa.DateTime(), nullable=False),
    sa.Column('contributor_id', sa.Integer(), nullable=False),
    sa.Column('poll_id', sa.Integer(), nullable=False),
    sa.Column('votes_count', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['contributor_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['poll_id'], ['poll.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_recipe_date_added'), 'recipe', ['date_added'], unique=False)
    op.create_index(op.f('ix_recipe_name'), 'recipe', ['name'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_recipe_name'), table_name='recipe')
    op.drop_index(op.f('ix_recipe_date_added'), table_name='recipe')
    op.drop_table('recipe')
    op.drop_index(op.f('ix_poll_name'), table_name='poll')
    op.drop_index(op.f('ix_poll_date_created'), table_name='poll')
    op.drop_table('poll')
    op.drop_table('vote')
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_index(op.f('ix_user_date_registered'), table_name='user')
    op.drop_table('user')
    # ### end Alembic commands ###
