"""empty message

Revision ID: 330a63f9e1eb
Revises: 
Create Date: 2018-12-17 21:28:58.338984

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import FetchedValue


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('courses',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=70), nullable=False),
    sa.Column('holeCount', sa.Integer(), nullable=False),
    sa.Column('cost', sa.Numeric(precision=2, scale=0), nullable=True),
    sa.Column('phone', sa.String(length=16), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=45), nullable=False),
    sa.Column('email', sa.String(length=100), nullable=False),
    sa.Column('password', sa.String(length=50), nullable=False),
    sa.Column('confirmed_at', sa.DateTime(), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('holes',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('course', sa.Integer(), nullable=False),
    sa.Column('holeNumber', sa.Integer(), nullable=False),
    sa.Column('par', sa.Integer(), nullable=False),
    sa.Column('handicap', sa.Integer(), nullable=True),
    sa.Column('blueLength', sa.SmallInteger(), nullable=False),
    sa.Column('whitelength', sa.SmallInteger(), nullable=True),
    sa.Column('blacklength', sa.SmallInteger(), nullable=True),
    sa.ForeignKeyConstraint(['course'], ['courses.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_holes_course'), 'holes', ['course'], unique=False)
    op.create_table('roles_users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('role_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('rounds',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('course', sa.Integer(), nullable=False),
    sa.Column('date', sa.Date(), nullable=False),
    sa.Column('start', sa.Time(), nullable=False),
    sa.Column('end', sa.Time(), nullable=False),
    sa.ForeignKeyConstraint(['course'], ['courses.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_rounds_course'), 'rounds', ['course'], unique=False)
    op.create_table('pairings',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('round', sa.Integer(), server_default=FetchedValue(), nullable=False),
    sa.Column('user', sa.Integer(), server_default=FetchedValue(), nullable=False),
    sa.ForeignKeyConstraint(['round'], ['rounds.id'], ),
    sa.ForeignKeyConstraint(['user'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_pairings_round'), 'pairings', ['round'], unique=False)
    op.create_index(op.f('ix_pairings_user'), 'pairings', ['user'], unique=False)
    op.create_table('scores',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('round', sa.Integer(), nullable=False),
    sa.Column('hole', sa.Integer(), nullable=False),
    sa.Column('user', sa.Integer(), nullable=False),
    sa.Column('score', sa.Integer(), nullable=False),
    sa.Column('gir', sa.Boolean(), nullable=False),
    sa.Column('fir', sa.Boolean(create_constraint=2), nullable=False),
    sa.Column('putts', sa.Integer(), nullable=False),
    sa.Column('chips', sa.Integer(), nullable=False),
    sa.Column('penaties', sa.Integer(), nullable=False),
    sa.Column('gsbunker', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['hole'], ['holes.id'], ),
    sa.ForeignKeyConstraint(['round'], ['rounds.id'], ),
    sa.ForeignKeyConstraint(['user'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_scores_hole'), 'scores', ['hole'], unique=False)
    op.create_index(op.f('ix_scores_round'), 'scores', ['round'], unique=False)
    op.create_index(op.f('ix_scores_user'), 'scores', ['user'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_scores_user'), table_name='scores')
    op.drop_index(op.f('ix_scores_round'), table_name='scores')
    op.drop_index(op.f('ix_scores_hole'), table_name='scores')
    op.drop_table('scores')
    op.drop_index(op.f('ix_pairings_user'), table_name='pairings')
    op.drop_index(op.f('ix_pairings_round'), table_name='pairings')
    op.drop_table('pairings')
    op.drop_index(op.f('ix_rounds_course'), table_name='rounds')
    op.drop_table('rounds')
    op.drop_table('roles_users')
    op.drop_index(op.f('ix_holes_course'), table_name='holes')
    op.drop_table('holes')
    op.drop_table('users')
    op.drop_table('roles')
    op.drop_table('courses')
    # ### end Alembic commands ###
