2019-10-02 20:55:09 +00:00
|
|
|
"""empty message
|
|
|
|
|
2019-10-13 17:15:03 +00:00
|
|
|
Revision ID: 77a6ccbab312
|
2019-10-02 20:55:09 +00:00
|
|
|
Revises:
|
2019-10-13 17:15:03 +00:00
|
|
|
Create Date: 2019-10-12 19:28:48.173762
|
2019-10-02 20:55:09 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
|
|
import sqlalchemy as sa
|
|
|
|
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
2019-10-13 17:15:03 +00:00
|
|
|
revision = '77a6ccbab312'
|
2019-10-02 20:55:09 +00:00
|
|
|
down_revision = None
|
|
|
|
branch_labels = None
|
|
|
|
depends_on = None
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade():
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
2019-10-11 00:41:49 +00:00
|
|
|
op.create_table('game_rooms',
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('name', sa.String(length=40), nullable=False),
|
2019-10-11 00:41:49 +00:00
|
|
|
sa.Column('description', sa.String(length=200), nullable=False),
|
|
|
|
sa.Column('private', sa.Boolean(), nullable=False),
|
|
|
|
sa.Column('language', sa.Enum('EN', name='languages'), nullable=False),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.PrimaryKeyConstraint('id')
|
|
|
|
)
|
|
|
|
op.create_table('users',
|
|
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
2019-10-10 21:57:29 +00:00
|
|
|
sa.Column('username', sa.String(length=255), autoincrement=True, nullable=False),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.Column('email', sa.String(length=255), nullable=False),
|
2019-10-06 06:57:36 +00:00
|
|
|
sa.Column('password', sa.String(length=255), nullable=False),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.Column('registered_on', sa.DateTime(), nullable=False),
|
|
|
|
sa.Column('admin', sa.Boolean(), nullable=False),
|
2019-10-10 21:57:29 +00:00
|
|
|
sa.Column('rank', sa.Enum('D7', 'D6', 'D5', 'D4', 'D3', 'D2', 'D1', 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'K10', 'K11', 'K12', 'K13', 'K14', 'K15', 'K16', 'K17', 'K18', 'K19', 'K20', 'K21', 'K22', 'K23', 'K24', 'K25', 'K26', 'K27', 'K28', 'K29', 'K30', 'UR', name='ranks'), nullable=True),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.Column('elo', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('rank_certainty', sa.Boolean(), nullable=False),
|
|
|
|
sa.PrimaryKeyConstraint('id'),
|
2019-10-10 21:57:29 +00:00
|
|
|
sa.UniqueConstraint('email'),
|
|
|
|
sa.UniqueConstraint('username')
|
|
|
|
)
|
|
|
|
op.create_table('game_rooms_users',
|
|
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
|
|
sa.Column('game_rooms_id', sa.Integer(), nullable=False),
|
|
|
|
sa.ForeignKeyConstraint(['game_rooms_id'], ['game_rooms.id'], ),
|
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
|
sa.PrimaryKeyConstraint('user_id', 'game_rooms_id')
|
2019-10-02 20:55:09 +00:00
|
|
|
)
|
|
|
|
op.create_table('games',
|
|
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('date', sa.DateTime(), nullable=True),
|
|
|
|
sa.Column('komi', sa.Numeric(precision=2, scale=1), nullable=False),
|
|
|
|
sa.Column('handicap', sa.Integer(), nullable=False),
|
|
|
|
sa.Column('board_size', sa.Integer(), nullable=False),
|
|
|
|
sa.Column('win_type', sa.Enum('DRAW', 'RESIGN', 'SCORE', 'TIME', 'VOID', name='wintype'), nullable=True),
|
|
|
|
sa.Column('winner', sa.Enum('BLACK', 'WHITE', 'VOID', name='players'), nullable=True),
|
|
|
|
sa.Column('score', sa.Numeric(precision=2, scale=1), nullable=True),
|
|
|
|
sa.Column('white_captures', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('black_captures', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('application', sa.String(length=40), nullable=True),
|
|
|
|
sa.Column('application_version', sa.String(length=20), nullable=True),
|
|
|
|
sa.Column('event', sa.String(length=40), nullable=True),
|
|
|
|
sa.Column('name', sa.String(length=40), nullable=True),
|
|
|
|
sa.Column('description', sa.String(length=200), nullable=True),
|
|
|
|
sa.Column('round', sa.Integer(), nullable=True),
|
2019-10-11 00:41:49 +00:00
|
|
|
sa.Column('main_time', sa.Enum('BYOYOMI', 'ABSOLUTE', 'HOURGLASS', 'NONE', name='timetypes'), nullable=False),
|
|
|
|
sa.Column('time_period', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('period_length', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('overtime', sa.Enum('BYOYOMI', 'ABSOLUTE', 'HOURGLASS', 'NONE', name='timetypes'), nullable=False),
|
|
|
|
sa.Column('overtime_period', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('overtime_length', sa.Integer(), nullable=True),
|
2019-10-11 00:52:43 +00:00
|
|
|
sa.Column('game_room', sa.Integer(), nullable=True),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.Column('player_black', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('player_white', sa.Integer(), nullable=True),
|
2019-10-11 00:52:43 +00:00
|
|
|
sa.ForeignKeyConstraint(['game_room'], ['game_rooms.id'], ),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.ForeignKeyConstraint(['player_black'], ['users.id'], ),
|
|
|
|
sa.ForeignKeyConstraint(['player_white'], ['users.id'], ),
|
|
|
|
sa.PrimaryKeyConstraint('id')
|
|
|
|
)
|
2019-10-11 00:41:49 +00:00
|
|
|
op.create_table('games_users',
|
|
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
|
|
sa.Column('game_rooms_id', sa.Integer(), nullable=False),
|
|
|
|
sa.ForeignKeyConstraint(['game_rooms_id'], ['games.id'], ),
|
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
|
sa.PrimaryKeyConstraint('user_id', 'game_rooms_id')
|
|
|
|
)
|
2019-10-02 20:55:09 +00:00
|
|
|
op.create_table('moves',
|
|
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('player', sa.Enum('BLACK', 'WHITE', name='players'), nullable=True),
|
|
|
|
sa.Column('x_point', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('y_point', sa.Integer(), nullable=True),
|
|
|
|
sa.Column('move_number', sa.Integer(), nullable=True),
|
2019-10-10 21:57:29 +00:00
|
|
|
sa.Column('is_pass', sa.Boolean(), nullable=False),
|
|
|
|
sa.Column('is_main', sa.Boolean(), nullable=False),
|
2019-10-11 00:52:43 +00:00
|
|
|
sa.Column('game', sa.Integer(), nullable=False),
|
|
|
|
sa.Column('preceding_move', sa.Integer(), nullable=True),
|
|
|
|
sa.ForeignKeyConstraint(['game'], ['games.id'], ),
|
|
|
|
sa.ForeignKeyConstraint(['preceding_move'], ['moves.id'], ),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.PrimaryKeyConstraint('id')
|
|
|
|
)
|
|
|
|
op.create_table('messages',
|
|
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
|
|
sa.Column('date', sa.DateTime(), nullable=False),
|
|
|
|
sa.Column('content', sa.String(length=200), nullable=False),
|
2019-10-11 00:52:43 +00:00
|
|
|
sa.Column('move', sa.Integer(), nullable=False),
|
|
|
|
sa.ForeignKeyConstraint(['move'], ['moves.id'], ),
|
2019-10-02 20:55:09 +00:00
|
|
|
sa.PrimaryKeyConstraint('id')
|
|
|
|
)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade():
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
|
|
op.drop_table('messages')
|
|
|
|
op.drop_table('moves')
|
2019-10-11 00:41:49 +00:00
|
|
|
op.drop_table('games_users')
|
2019-10-02 20:55:09 +00:00
|
|
|
op.drop_table('games')
|
2019-10-10 21:57:29 +00:00
|
|
|
op.drop_table('game_rooms_users')
|
2019-10-02 20:55:09 +00:00
|
|
|
op.drop_table('users')
|
2019-10-11 00:41:49 +00:00
|
|
|
op.drop_table('game_rooms')
|
2019-10-02 20:55:09 +00:00
|
|
|
# ### end Alembic commands ###
|