You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
5.1 KiB
117 lines
5.1 KiB
4 years ago
|
"""update to 1.3
|
||
4 years ago
|
|
||
4 years ago
|
Revision ID: 01c009738a1f
|
||
4 years ago
|
Revises:
|
||
4 years ago
|
Create Date: 2020-07-03 13:12:00.463246
|
||
4 years ago
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
4 years ago
|
revision = '01c009738a1f'
|
||
4 years ago
|
down_revision = None
|
||
4 years ago
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
4 years ago
|
op.create_table('game',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=64), nullable=False),
|
||
|
sa.Column('state', sa.Integer(), server_default='1', nullable=True),
|
||
|
sa.Column('start_time', sa.DateTime(), nullable=True),
|
||
|
sa.Column('end_time', sa.DateTime(), nullable=True),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_index(op.f('ix_game_name'), 'game', ['name'], unique=True)
|
||
|
op.create_table('player',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=64), nullable=False),
|
||
4 years ago
|
sa.Column('auth_hash', sa.String(length=32), nullable=True),
|
||
4 years ago
|
sa.Column('password_hash', sa.String(length=128), nullable=True),
|
||
|
sa.PrimaryKeyConstraint('id'),
|
||
|
sa.UniqueConstraint('auth_hash'),
|
||
|
sa.UniqueConstraint('name')
|
||
|
)
|
||
|
op.create_table('game_player',
|
||
|
sa.Column('game_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('player_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('role', sa.String(length=16), nullable=True),
|
||
|
sa.ForeignKeyConstraint(['game_id'], ['game.id'], ),
|
||
|
sa.ForeignKeyConstraint(['player_id'], ['player.id'], ),
|
||
|
sa.PrimaryKeyConstraint('game_id', 'player_id')
|
||
|
)
|
||
4 years ago
|
op.create_table('location',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('player_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('longitude', sa.Numeric(precision=15, scale=10, asdecimal=False), nullable=False),
|
||
|
sa.Column('latitude', sa.Numeric(precision=15, scale=10, asdecimal=False), nullable=False),
|
||
|
sa.Column('timestamp', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['player_id'], ['player.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_table('notification',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('game_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('message', sa.Text(), nullable=False),
|
||
|
sa.Column('type', sa.String(length=64), nullable=False),
|
||
|
sa.Column('timestamp', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['game_id'], ['game.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_table('objective',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=64), nullable=False),
|
||
|
sa.Column('game_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('hash', sa.String(length=128), nullable=False),
|
||
|
sa.Column('longitude', sa.Numeric(precision=15, scale=10, asdecimal=False), nullable=True),
|
||
|
sa.Column('latitude', sa.Numeric(precision=15, scale=10, asdecimal=False), nullable=True),
|
||
|
sa.ForeignKeyConstraint(['game_id'], ['game.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id'),
|
||
|
sa.UniqueConstraint('hash')
|
||
|
)
|
||
|
op.create_table('player_caught_player',
|
||
|
sa.Column('catching_player_id', sa.Integer(), nullable=True),
|
||
|
sa.Column('caught_player_id', sa.Integer(), nullable=True),
|
||
|
sa.Column('photo_reference', sa.String(length=128), nullable=False),
|
||
|
sa.Column('timestamp', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['catching_player_id'], ['player.id'], ),
|
||
|
sa.ForeignKeyConstraint(['caught_player_id'], ['player.id'], ),
|
||
|
sa.UniqueConstraint('photo_reference')
|
||
|
)
|
||
|
op.create_table('notification_player',
|
||
|
sa.Column('notification_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('player_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('been_shown', sa.Boolean(), server_default='True', nullable=False),
|
||
|
sa.ForeignKeyConstraint(['notification_id'], ['notification.id'], ),
|
||
|
sa.ForeignKeyConstraint(['player_id'], ['player.id'], ),
|
||
|
sa.PrimaryKeyConstraint('notification_id', 'player_id')
|
||
|
)
|
||
4 years ago
|
op.create_table('player_found_objective',
|
||
|
sa.Column('objective_id', sa.Integer(), server_default='-1', nullable=False),
|
||
|
sa.Column('player_id', sa.Integer(), server_default='-1', nullable=False),
|
||
|
sa.Column('timestamp', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['objective_id'], ['objective.id'], ),
|
||
|
sa.ForeignKeyConstraint(['player_id'], ['player.id'], ),
|
||
|
sa.PrimaryKeyConstraint('objective_id', 'player_id')
|
||
|
)
|
||
4 years ago
|
# ### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.drop_table('player_found_objective')
|
||
4 years ago
|
op.drop_table('notification_player')
|
||
4 years ago
|
op.drop_table('player_caught_player')
|
||
|
op.drop_table('objective')
|
||
|
op.drop_table('notification')
|
||
|
op.drop_table('location')
|
||
4 years ago
|
op.drop_table('game_player')
|
||
|
op.drop_table('player')
|
||
|
op.drop_index(op.f('ix_game_name'), table_name='game')
|
||
|
op.drop_table('game')
|
||
4 years ago
|
# ### end Alembic commands ###
|