From 64b2d129eba4caf270ea4a61483690e0f31531bf Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Tue, 10 Dec 2024 16:45:06 -0800 Subject: [PATCH] refactor(migrations): Consolidate migrations Consolidate multiple migration files into a single migration file to help the database prepare for production. --- ..._add_column_players_teams_availability_.py | 32 ---- .../131efbdd7af4_add_playerevent_models.py | 36 ---- ...c9a051a0a6_add_team_integrations_models.py | 41 ---- .../migrations/versions/273f73c81783_.py | 33 ---- ...6ee26b9e5d_add_event_discord_message_id.py | 32 ---- ...55_add_player_event_player_team_role_id.py | 34 ---- ...9af_rename_players_teams_roles_id_to_id.py | 42 ----- ...2f3ae2ec7f_make_player_role_primary_key.py | 26 --- ...91293_change_integrations_to_one_to_one.py | 42 ----- .../migrations/versions/3b18d4bfc6ac_.py | 176 ++++++++++++++++++ .../47f0722b02b0_add_availability_index.py | 34 ---- ...rename_table_players_teams_availability.py | 44 ----- .../versions/5debac4cdf37_add_events.py | 46 ----- ...b_add_surrogate_key_to_player_team_and_.py | 64 ------- .../versions/65714d7e78f8_add_teaminvite.py | 35 ---- ...7_change_player_team_surrogate_key_name.py | 50 ----- .../versions/7361c978e53d_fix_integrity.py | 40 ---- ...4ef2cc_add_the_rest_of_the_match_tables.py | 56 ------ ..._make_playerteamavailability_a_db_model.py | 35 ---- ...8df14798d5_add_team_discord_webhook_url.py | 32 ---- .../a340b3da0f2a_add_auth_session_key.py | 32 ---- .../migrations/versions/b00632365b58_.py | 42 ----- ...242e3f99c64_add_webhook_profile_picture.py | 32 ---- .../ce676db8c655_initial_migration.py | 61 ------ ...5570037f47_change_intervals_to_integers.py | 50 ----- .../dcf5ffd0ec73_add_has_confirmed_column.py | 38 ---- .../ea359b0e46d7_add_team_tz_timezone.py | 55 ------ ...a79c4ae22_add_playerteam_is_team_leader.py | 32 ---- .../f802d763a7b4_drop_integrations_tables.py | 28 --- .../versions/fda727438444_add_match_table.py | 35 ---- 30 files changed, 176 insertions(+), 1159 deletions(-) delete mode 100644 backend-flask/migrations/versions/062a154a0797_add_column_players_teams_availability_.py delete mode 100644 backend-flask/migrations/versions/131efbdd7af4_add_playerevent_models.py delete mode 100644 backend-flask/migrations/versions/1fc9a051a0a6_add_team_integrations_models.py delete mode 100644 backend-flask/migrations/versions/273f73c81783_.py delete mode 100644 backend-flask/migrations/versions/286ee26b9e5d_add_event_discord_message_id.py delete mode 100644 backend-flask/migrations/versions/2a33f577d655_add_player_event_player_team_role_id.py delete mode 100644 backend-flask/migrations/versions/2b05ba5ba9af_rename_players_teams_roles_id_to_id.py delete mode 100644 backend-flask/migrations/versions/2b2f3ae2ec7f_make_player_role_primary_key.py delete mode 100644 backend-flask/migrations/versions/392454b91293_change_integrations_to_one_to_one.py create mode 100644 backend-flask/migrations/versions/3b18d4bfc6ac_.py delete mode 100644 backend-flask/migrations/versions/47f0722b02b0_add_availability_index.py delete mode 100644 backend-flask/migrations/versions/4fb63c11ee8c_rename_table_players_teams_availability.py delete mode 100644 backend-flask/migrations/versions/5debac4cdf37_add_events.py delete mode 100644 backend-flask/migrations/versions/6296c347731b_add_surrogate_key_to_player_team_and_.py delete mode 100644 backend-flask/migrations/versions/65714d7e78f8_add_teaminvite.py delete mode 100644 backend-flask/migrations/versions/6e9d70f835d7_change_player_team_surrogate_key_name.py delete mode 100644 backend-flask/migrations/versions/7361c978e53d_fix_integrity.py delete mode 100644 backend-flask/migrations/versions/7995474ef2cc_add_the_rest_of_the_match_tables.py delete mode 100644 backend-flask/migrations/versions/8ea29cf493f5_make_playerteamavailability_a_db_model.py delete mode 100644 backend-flask/migrations/versions/958df14798d5_add_team_discord_webhook_url.py delete mode 100644 backend-flask/migrations/versions/a340b3da0f2a_add_auth_session_key.py delete mode 100644 backend-flask/migrations/versions/b00632365b58_.py delete mode 100644 backend-flask/migrations/versions/c242e3f99c64_add_webhook_profile_picture.py delete mode 100644 backend-flask/migrations/versions/ce676db8c655_initial_migration.py delete mode 100644 backend-flask/migrations/versions/d15570037f47_change_intervals_to_integers.py delete mode 100644 backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py delete mode 100644 backend-flask/migrations/versions/ea359b0e46d7_add_team_tz_timezone.py delete mode 100644 backend-flask/migrations/versions/f50a79c4ae22_add_playerteam_is_team_leader.py delete mode 100644 backend-flask/migrations/versions/f802d763a7b4_drop_integrations_tables.py delete mode 100644 backend-flask/migrations/versions/fda727438444_add_match_table.py diff --git a/backend-flask/migrations/versions/062a154a0797_add_column_players_teams_availability_.py b/backend-flask/migrations/versions/062a154a0797_add_column_players_teams_availability_.py deleted file mode 100644 index 3688a54..0000000 --- a/backend-flask/migrations/versions/062a154a0797_add_column_players_teams_availability_.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add column players_teams_availability.availability - -Revision ID: 062a154a0797 -Revises: 4fb63c11ee8c -Create Date: 2024-10-30 23:54:22.877218 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '062a154a0797' -down_revision = '4fb63c11ee8c' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.add_column(sa.Column('availability', sa.Integer(), nullable=False, default=2)) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.drop_column('availability') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/131efbdd7af4_add_playerevent_models.py b/backend-flask/migrations/versions/131efbdd7af4_add_playerevent_models.py deleted file mode 100644 index 5b24cf9..0000000 --- a/backend-flask/migrations/versions/131efbdd7af4_add_playerevent_models.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Add PlayerEvent models - -Revision ID: 131efbdd7af4 -Revises: 1fc9a051a0a6 -Create Date: 2024-11-19 10:16:34.289124 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '131efbdd7af4' -down_revision = '1fc9a051a0a6' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('team_discord_integrations', schema=None) as batch_op: - batch_op.alter_column('webhook_url', - existing_type=sa.VARCHAR(length=255), - nullable=True) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('team_discord_integrations', schema=None) as batch_op: - batch_op.alter_column('webhook_url', - existing_type=sa.VARCHAR(length=255), - nullable=False) - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/1fc9a051a0a6_add_team_integrations_models.py b/backend-flask/migrations/versions/1fc9a051a0a6_add_team_integrations_models.py deleted file mode 100644 index 53c289a..0000000 --- a/backend-flask/migrations/versions/1fc9a051a0a6_add_team_integrations_models.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Add team integrations models - -Revision ID: 1fc9a051a0a6 -Revises: 65714d7e78f8 -Create Date: 2024-11-11 19:12:42.611838 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '1fc9a051a0a6' -down_revision = '65714d7e78f8' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('team_integrations', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('integration_type', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('team_discord_integrations', - sa.Column('integration_id', sa.Integer(), nullable=False), - sa.Column('webhook_url', sa.String(length=255), nullable=False), - sa.ForeignKeyConstraint(['integration_id'], ['team_integrations.id'], ), - sa.PrimaryKeyConstraint('integration_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('team_discord_integrations') - op.drop_table('team_integrations') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/273f73c81783_.py b/backend-flask/migrations/versions/273f73c81783_.py deleted file mode 100644 index d3166b8..0000000 --- a/backend-flask/migrations/versions/273f73c81783_.py +++ /dev/null @@ -1,33 +0,0 @@ -"""empty message - -Revision ID: 273f73c81783 -Revises: ce676db8c655 -Create Date: 2024-10-29 23:12:40.743611 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '273f73c81783' -down_revision = 'ce676db8c655' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('auth_session', - sa.Column('player_id', sa.BigInteger(), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), - sa.PrimaryKeyConstraint('player_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('auth_session') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/286ee26b9e5d_add_event_discord_message_id.py b/backend-flask/migrations/versions/286ee26b9e5d_add_event_discord_message_id.py deleted file mode 100644 index 89e08eb..0000000 --- a/backend-flask/migrations/versions/286ee26b9e5d_add_event_discord_message_id.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add event.discord_message_id - -Revision ID: 286ee26b9e5d -Revises: 392454b91293 -Create Date: 2024-11-25 21:00:08.444434 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '286ee26b9e5d' -down_revision = '392454b91293' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('events', schema=None) as batch_op: - batch_op.add_column(sa.Column('discord_message_id', sa.BigInteger(), nullable=True)) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('events', schema=None) as batch_op: - batch_op.drop_column('discord_message_id') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/2a33f577d655_add_player_event_player_team_role_id.py b/backend-flask/migrations/versions/2a33f577d655_add_player_event_player_team_role_id.py deleted file mode 100644 index 0ab4023..0000000 --- a/backend-flask/migrations/versions/2a33f577d655_add_player_event_player_team_role_id.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Add player_event.player_team_role_id - -Revision ID: 2a33f577d655 -Revises: 2b05ba5ba9af -Create Date: 2024-11-24 16:29:03.546231 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '2a33f577d655' -down_revision = '2b05ba5ba9af' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_events', schema=None) as batch_op: - batch_op.add_column(sa.Column('player_team_role_id', sa.Integer(), nullable=False)) - batch_op.create_foreign_key('fk_players_events_player_team_role_id_players_teams_roles', 'players_teams_roles', ['player_team_role_id'], ['id']) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_events', schema=None) as batch_op: - batch_op.drop_constraint('fk_players_events_player_team_role_id_players_teams_roles', type_='foreignkey') - batch_op.drop_column('player_team_role_id') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/2b05ba5ba9af_rename_players_teams_roles_id_to_id.py b/backend-flask/migrations/versions/2b05ba5ba9af_rename_players_teams_roles_id_to_id.py deleted file mode 100644 index 67da94c..0000000 --- a/backend-flask/migrations/versions/2b05ba5ba9af_rename_players_teams_roles_id_to_id.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Rename players_teams_roles_id to id - -Revision ID: 2b05ba5ba9af -Revises: 47f0722b02b0 -Create Date: 2024-11-24 15:58:36.018191 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '2b05ba5ba9af' -down_revision = '47f0722b02b0' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('events', schema=None) as batch_op: - batch_op.create_unique_constraint('uq_events_team_id', ['team_id', 'name', 'start_time']) - - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - #batch_op.add_column(sa.Column('id', sa.Integer(), autoincrement=True, nullable=False)) - #batch_op.drop_column('player_team_role_id') - batch_op.alter_column('player_team_role_id', new_column_name='id') - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.alter_column('id', new_column_name='player_team_role_id') - #batch_op.add_column(sa.Column('player_team_role_id', sa.INTEGER(), nullable=False)) - #batch_op.drop_column('id') - - with op.batch_alter_table('events', schema=None) as batch_op: - batch_op.drop_constraint('uq_events_team_id', type_='unique') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/2b2f3ae2ec7f_make_player_role_primary_key.py b/backend-flask/migrations/versions/2b2f3ae2ec7f_make_player_role_primary_key.py deleted file mode 100644 index 3a38700..0000000 --- a/backend-flask/migrations/versions/2b2f3ae2ec7f_make_player_role_primary_key.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Make player role primary key - -Revision ID: 2b2f3ae2ec7f -Revises: 958df14798d5 -Create Date: 2024-10-31 19:07:02.960849 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '2b2f3ae2ec7f' -down_revision = '958df14798d5' -branch_labels = None -depends_on = None - - -def upgrade(): - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.create_primary_key('pk_players_teams_roles', ['player_id', 'team_id', 'role']) - - -def downgrade(): - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.drop_constraint('pk_players_teams_roles') diff --git a/backend-flask/migrations/versions/392454b91293_change_integrations_to_one_to_one.py b/backend-flask/migrations/versions/392454b91293_change_integrations_to_one_to_one.py deleted file mode 100644 index 4d3152e..0000000 --- a/backend-flask/migrations/versions/392454b91293_change_integrations_to_one_to_one.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Change integrations to one-to-one - -Revision ID: 392454b91293 -Revises: f802d763a7b4 -Create Date: 2024-11-25 18:36:15.293593 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '392454b91293' -down_revision = 'f802d763a7b4' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('team_discord_integrations', - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('webhook_url', sa.String(), nullable=False), - sa.Column('webhook_bot_name', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), - sa.PrimaryKeyConstraint('team_id') - ) - op.create_table('team_logs_tf_integrations', - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('logs_tf_api_key', sa.String(), nullable=True), - sa.Column('min_team_member_count', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), - sa.PrimaryKeyConstraint('team_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('team_logs_tf_integrations') - op.drop_table('team_discord_integrations') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/3b18d4bfc6ac_.py b/backend-flask/migrations/versions/3b18d4bfc6ac_.py new file mode 100644 index 0000000..db18333 --- /dev/null +++ b/backend-flask/migrations/versions/3b18d4bfc6ac_.py @@ -0,0 +1,176 @@ +"""empty message + +Revision ID: 3b18d4bfc6ac +Revises: +Create Date: 2024-12-10 16:43:29.354244 + +""" +from alembic import op +import sqlalchemy as sa +import sqlalchemy_utc + + +# revision identifiers, used by Alembic. +revision = '3b18d4bfc6ac' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('matches', + sa.Column('logs_tf_id', sa.Integer(), nullable=False), + sa.Column('logs_tf_title', sa.String(length=255), nullable=False), + sa.Column('duration', sa.Integer(), nullable=False), + sa.Column('match_time', sa.TIMESTAMP(), nullable=False), + sa.Column('blue_score', sa.Integer(), nullable=False), + sa.Column('red_score', sa.Integer(), nullable=False), + sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), + sa.PrimaryKeyConstraint('logs_tf_id') + ) + op.create_table('players', + sa.Column('steam_id', sa.BigInteger(), nullable=False), + sa.Column('username', sa.String(length=63), nullable=False), + sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), + sa.PrimaryKeyConstraint('steam_id') + ) + op.create_table('teams', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('team_name', sa.String(length=63), nullable=False), + sa.Column('discord_webhook_url', sa.String(length=255), nullable=True), + sa.Column('tz_timezone', sa.String(length=31), nullable=False), + sa.Column('minute_offset', sa.SmallInteger(), nullable=False), + sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('team_name') + ) + op.create_table('auth_sessions', + sa.Column('key', sa.String(length=31), nullable=False), + sa.Column('player_id', sa.BigInteger(), nullable=False), + sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), + sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), + sa.PrimaryKeyConstraint('key') + ) + op.create_table('events', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('team_id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=255), nullable=False), + sa.Column('start_time', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), + sa.Column('description', sa.Text(), nullable=True), + sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), + sa.Column('discord_message_id', sa.BigInteger(), nullable=True), + sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('team_id', 'name', 'start_time') + ) + op.create_table('players_matches', + sa.Column('player_id', sa.BigInteger(), nullable=False), + sa.Column('match_id', sa.Integer(), nullable=False), + sa.Column('kills', sa.Integer(), nullable=False), + sa.Column('deaths', sa.Integer(), nullable=False), + sa.Column('assists', sa.Integer(), nullable=False), + sa.Column('damage', sa.BigInteger(), nullable=False), + sa.Column('damage_taken', sa.BigInteger(), nullable=False), + sa.ForeignKeyConstraint(['match_id'], ['matches.logs_tf_id'], ), + sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), + sa.PrimaryKeyConstraint('player_id', 'match_id') + ) + op.create_table('players_teams', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('player_id', sa.BigInteger(), nullable=False), + sa.Column('team_id', sa.Integer(), nullable=False), + sa.Column('team_role', sa.Enum('Player', 'CoachMentor', name='teamrole'), nullable=False), + sa.Column('playtime', sa.Integer(), nullable=False), + sa.Column('is_team_leader', sa.Boolean(), nullable=False), + sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), + sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), + sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('team_discord_integrations', + sa.Column('team_id', sa.Integer(), nullable=False), + sa.Column('webhook_url', sa.String(), nullable=False), + sa.Column('webhook_bot_name', sa.String(), nullable=False), + sa.Column('webhook_bot_profile_picture', sa.String(length=255), nullable=True), + sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), + sa.PrimaryKeyConstraint('team_id') + ) + op.create_table('team_invites', + sa.Column('key', sa.String(length=31), nullable=False), + sa.Column('team_id', sa.Integer(), nullable=False), + sa.Column('delete_on_use', sa.Boolean(), nullable=False), + sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), + sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), + sa.PrimaryKeyConstraint('key') + ) + op.create_table('team_logs_tf_integrations', + sa.Column('team_id', sa.Integer(), nullable=False), + sa.Column('logs_tf_api_key', sa.String(), nullable=True), + sa.Column('min_team_member_count', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), + sa.PrimaryKeyConstraint('team_id') + ) + op.create_table('teams_matches', + sa.Column('team_id', sa.Integer(), nullable=False), + sa.Column('match_id', sa.Integer(), nullable=False), + sa.Column('team_color', sa.String(length=4), nullable=False), + sa.ForeignKeyConstraint(['match_id'], ['matches.logs_tf_id'], ), + sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), + sa.PrimaryKeyConstraint('team_id', 'match_id') + ) + op.create_table('players_teams_availability', + sa.Column('player_team_id', sa.Integer(), nullable=False), + sa.Column('start_time', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), + sa.Column('availability', sa.Integer(), nullable=False), + sa.Column('end_time', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), + sa.ForeignKeyConstraint(['player_team_id'], ['players_teams.id'], ), + sa.PrimaryKeyConstraint('player_team_id', 'start_time') + ) + with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_players_teams_availability_end_time'), ['end_time'], unique=False) + batch_op.create_index(batch_op.f('ix_players_teams_availability_start_time'), ['start_time'], unique=False) + + op.create_table('players_teams_roles', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('player_team_id', sa.Integer(), nullable=False), + sa.Column('role', sa.Enum('Unknown', 'Scout', 'PocketScout', 'FlankScout', 'Soldier', 'PocketSoldier', 'Roamer', 'Pyro', 'Demoman', 'HeavyWeapons', 'Engineer', 'Medic', 'Sniper', 'Spy', name='role'), nullable=False), + sa.Column('is_main', sa.Boolean(), nullable=False), + sa.ForeignKeyConstraint(['player_team_id'], ['players_teams.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('player_team_id', 'role') + ) + op.create_table('players_events', + sa.Column('event_id', sa.Integer(), nullable=False), + sa.Column('player_id', sa.BigInteger(), nullable=False), + sa.Column('player_team_role_id', sa.Integer(), nullable=True), + sa.Column('has_confirmed', sa.Boolean(), nullable=False), + sa.ForeignKeyConstraint(['event_id'], ['events.id'], ), + sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), + sa.ForeignKeyConstraint(['player_team_role_id'], ['players_teams_roles.id'], ), + sa.PrimaryKeyConstraint('event_id', 'player_id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('players_events') + op.drop_table('players_teams_roles') + with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_players_teams_availability_start_time')) + batch_op.drop_index(batch_op.f('ix_players_teams_availability_end_time')) + + op.drop_table('players_teams_availability') + op.drop_table('teams_matches') + op.drop_table('team_logs_tf_integrations') + op.drop_table('team_invites') + op.drop_table('team_discord_integrations') + op.drop_table('players_teams') + op.drop_table('players_matches') + op.drop_table('events') + op.drop_table('auth_sessions') + op.drop_table('teams') + op.drop_table('players') + op.drop_table('matches') + # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/47f0722b02b0_add_availability_index.py b/backend-flask/migrations/versions/47f0722b02b0_add_availability_index.py deleted file mode 100644 index 7db076f..0000000 --- a/backend-flask/migrations/versions/47f0722b02b0_add_availability_index.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Add availability index - -Revision ID: 47f0722b02b0 -Revises: 7361c978e53d -Create Date: 2024-11-21 13:10:45.098947 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '47f0722b02b0' -down_revision = '7361c978e53d' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_players_teams_availability_end_time'), ['end_time'], unique=False) - batch_op.create_index(batch_op.f('ix_players_teams_availability_start_time'), ['start_time'], unique=False) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_players_teams_availability_start_time')) - batch_op.drop_index(batch_op.f('ix_players_teams_availability_end_time')) - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/4fb63c11ee8c_rename_table_players_teams_availability.py b/backend-flask/migrations/versions/4fb63c11ee8c_rename_table_players_teams_availability.py deleted file mode 100644 index 0b94f0e..0000000 --- a/backend-flask/migrations/versions/4fb63c11ee8c_rename_table_players_teams_availability.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Rename table players_teams_availability - -Revision ID: 4fb63c11ee8c -Revises: 8ea29cf493f5 -Create Date: 2024-10-30 22:45:51.227298 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '4fb63c11ee8c' -down_revision = '8ea29cf493f5' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('players_teams_availability', - sa.Column('player_id', sa.Integer(), nullable=False), - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('start_time', sa.TIMESTAMP(), nullable=False), - sa.Column('end_time', sa.TIMESTAMP(), nullable=False), - sa.ForeignKeyConstraint(['player_id', 'team_id'], ['players_teams.player_id', 'players_teams.team_id'], ), - sa.PrimaryKeyConstraint('player_id', 'team_id', 'start_time') - ) - op.drop_table('player_team_availability') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('player_team_availability', - sa.Column('player_id', sa.INTEGER(), nullable=False), - sa.Column('team_id', sa.INTEGER(), nullable=False), - sa.Column('start_time', sa.TIMESTAMP(), nullable=False), - sa.Column('end_time', sa.TIMESTAMP(), nullable=False), - sa.ForeignKeyConstraint(['player_id', 'team_id'], ['players_teams.player_id', 'players_teams.team_id'], ), - sa.PrimaryKeyConstraint('player_id', 'team_id') - ) - op.drop_table('players_teams_availability') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/5debac4cdf37_add_events.py b/backend-flask/migrations/versions/5debac4cdf37_add_events.py deleted file mode 100644 index 4d2403a..0000000 --- a/backend-flask/migrations/versions/5debac4cdf37_add_events.py +++ /dev/null @@ -1,46 +0,0 @@ -"""Add Events - -Revision ID: 5debac4cdf37 -Revises: 131efbdd7af4 -Create Date: 2024-11-20 15:17:00.205485 - -""" -from alembic import op -import sqlalchemy as sa -import sqlalchemy_utc - - -# revision identifiers, used by Alembic. -revision = '5debac4cdf37' -down_revision = '131efbdd7af4' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('events', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('name', sa.String(length=255), nullable=False), - sa.Column('description', sa.Text(), nullable=True), - sa.Column('start_time', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=False), - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('players_events', - sa.Column('event_id', sa.Integer(), nullable=False), - sa.Column('player_id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['event_id'], ['events.id'], ), - sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), - sa.PrimaryKeyConstraint('event_id', 'player_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('players_events') - op.drop_table('events') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/6296c347731b_add_surrogate_key_to_player_team_and_.py b/backend-flask/migrations/versions/6296c347731b_add_surrogate_key_to_player_team_and_.py deleted file mode 100644 index a7108a4..0000000 --- a/backend-flask/migrations/versions/6296c347731b_add_surrogate_key_to_player_team_and_.py +++ /dev/null @@ -1,64 +0,0 @@ -"""Add surrogate key to player_team and others - -Revision ID: 6296c347731b -Revises: 5debac4cdf37 -Create Date: 2024-11-21 10:30:09.333087 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '6296c347731b' -down_revision = '5debac4cdf37' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.add_column(sa.Column('player_team_id', sa.Integer(), autoincrement=True, nullable=False)) - - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.add_column(sa.Column('player_team_id', sa.Integer(), nullable=False)) - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_team_id'], ['player_team_id']) - batch_op.drop_column('team_id') - batch_op.drop_column('player_id') - - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.add_column(sa.Column('player_team_role_id', sa.Integer(), autoincrement=True, nullable=False)) - batch_op.add_column(sa.Column('player_team_id', sa.Integer(), nullable=False)) - batch_op.create_unique_constraint(None, ['player_team_id', 'role']) - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_team_id'], ['player_team_id']) - batch_op.drop_column('team_id') - batch_op.drop_column('player_id') - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.add_column(sa.Column('player_id', sa.INTEGER(), nullable=False)) - batch_op.add_column(sa.Column('team_id', sa.INTEGER(), nullable=False)) - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_id', 'team_id'], ['player_id', 'team_id']) - batch_op.drop_constraint(None, type_='unique') - batch_op.drop_column('player_team_id') - batch_op.drop_column('player_team_role_id') - - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.add_column(sa.Column('player_id', sa.INTEGER(), nullable=False)) - batch_op.add_column(sa.Column('team_id', sa.INTEGER(), nullable=False)) - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_id', 'team_id'], ['player_id', 'team_id']) - batch_op.drop_column('player_team_id') - - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.drop_column('player_team_id') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/65714d7e78f8_add_teaminvite.py b/backend-flask/migrations/versions/65714d7e78f8_add_teaminvite.py deleted file mode 100644 index 19a9d29..0000000 --- a/backend-flask/migrations/versions/65714d7e78f8_add_teaminvite.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Add TeamInvite - -Revision ID: 65714d7e78f8 -Revises: f50a79c4ae22 -Create Date: 2024-11-08 23:16:04.669526 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '65714d7e78f8' -down_revision = 'f50a79c4ae22' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('team_invites', - sa.Column('key', sa.String(length=31), nullable=False), - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.Column('delete_on_use', sa.Boolean(), nullable=False), - sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), - sa.PrimaryKeyConstraint('key') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('team_invites') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/6e9d70f835d7_change_player_team_surrogate_key_name.py b/backend-flask/migrations/versions/6e9d70f835d7_change_player_team_surrogate_key_name.py deleted file mode 100644 index da98c1b..0000000 --- a/backend-flask/migrations/versions/6e9d70f835d7_change_player_team_surrogate_key_name.py +++ /dev/null @@ -1,50 +0,0 @@ -"""Change player_team surrogate key name - -Revision ID: 6e9d70f835d7 -Revises: 6296c347731b -Create Date: 2024-11-21 12:13:44.989797 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '6e9d70f835d7' -down_revision = '6296c347731b' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.add_column(sa.Column('id', sa.Integer(), autoincrement=True, nullable=False)) - batch_op.drop_column('player_team_id') - - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_team_id'], ['id']) - - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_team_id'], ['id']) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_team_id'], ['player_team_id']) - - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.create_foreign_key(None, 'players_teams', ['player_team_id'], ['player_team_id']) - - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.add_column(sa.Column('player_team_id', sa.INTEGER(), nullable=False)) - batch_op.drop_column('id') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/7361c978e53d_fix_integrity.py b/backend-flask/migrations/versions/7361c978e53d_fix_integrity.py deleted file mode 100644 index 7fe8a65..0000000 --- a/backend-flask/migrations/versions/7361c978e53d_fix_integrity.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Fix integrity - -Revision ID: 7361c978e53d -Revises: 6e9d70f835d7 -Create Date: 2024-11-21 12:43:01.786598 - -""" -from alembic import op -import sqlalchemy as sa - -import app_db - - -# revision identifiers, used by Alembic. -revision = '7361c978e53d' -down_revision = '6e9d70f835d7' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_availability', schema=None, naming_convention=app_db.convention) as batch_op: - batch_op.create_foreign_key(batch_op.f("fk_players_teams_availability_player_team_id_players_teams"), 'players_teams', ['player_team_id'], ['id']) - - with op.batch_alter_table('players_teams_roles', schema=None) as batch_op: - batch_op.create_foreign_key(batch_op.f("fk_players_teams_roles_player_team_id_players_teams"), 'players_teams', ['player_team_id'], ['id']) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_roles', schema=None, naming_convention=app_db.convention) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') - - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/7995474ef2cc_add_the_rest_of_the_match_tables.py b/backend-flask/migrations/versions/7995474ef2cc_add_the_rest_of_the_match_tables.py deleted file mode 100644 index 6785b73..0000000 --- a/backend-flask/migrations/versions/7995474ef2cc_add_the_rest_of_the_match_tables.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Add the rest of the match tables - -Revision ID: 7995474ef2cc -Revises: fda727438444 -Create Date: 2024-12-09 16:17:25.518959 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '7995474ef2cc' -down_revision = 'fda727438444' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('players_matches', - sa.Column('player_id', sa.BigInteger(), nullable=False), - sa.Column('match_id', sa.Integer(), nullable=False), - sa.Column('kills', sa.Integer(), nullable=False), - sa.Column('deaths', sa.Integer(), nullable=False), - sa.Column('assists', sa.Integer(), nullable=False), - sa.Column('damage', sa.BigInteger(), nullable=False), - sa.Column('damage_taken', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['match_id'], ['matches.logs_tf_id'], ), - sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), - sa.PrimaryKeyConstraint('player_id', 'match_id') - ) - op.create_table('teams_matches', - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('match_id', sa.Integer(), nullable=False), - sa.Column('team_color', sa.String(length=4), nullable=False), - sa.ForeignKeyConstraint(['match_id'], ['matches.logs_tf_id'], ), - sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), - sa.PrimaryKeyConstraint('team_id', 'match_id') - ) - with op.batch_alter_table('matches', schema=None) as batch_op: - batch_op.add_column(sa.Column('blue_score', sa.Integer(), nullable=False)) - batch_op.add_column(sa.Column('red_score', sa.Integer(), nullable=False)) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('matches', schema=None) as batch_op: - batch_op.drop_column('red_score') - batch_op.drop_column('blue_score') - - op.drop_table('teams_matches') - op.drop_table('players_matches') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/8ea29cf493f5_make_playerteamavailability_a_db_model.py b/backend-flask/migrations/versions/8ea29cf493f5_make_playerteamavailability_a_db_model.py deleted file mode 100644 index 430233f..0000000 --- a/backend-flask/migrations/versions/8ea29cf493f5_make_playerteamavailability_a_db_model.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Make PlayerTeamAvailability a db.Model - -Revision ID: 8ea29cf493f5 -Revises: b00632365b58 -Create Date: 2024-10-30 22:21:13.718428 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '8ea29cf493f5' -down_revision = 'b00632365b58' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('player_team_availability', - sa.Column('player_id', sa.Integer(), nullable=False), - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('start_time', sa.TIMESTAMP(), nullable=False), - sa.Column('end_time', sa.TIMESTAMP(), nullable=False), - sa.ForeignKeyConstraint(['player_id', 'team_id'], ['players_teams.player_id', 'players_teams.team_id'], ), - sa.PrimaryKeyConstraint('player_id', 'team_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('player_team_availability') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/958df14798d5_add_team_discord_webhook_url.py b/backend-flask/migrations/versions/958df14798d5_add_team_discord_webhook_url.py deleted file mode 100644 index c4028fd..0000000 --- a/backend-flask/migrations/versions/958df14798d5_add_team_discord_webhook_url.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add team.discord_webhook_url - -Revision ID: 958df14798d5 -Revises: 062a154a0797 -Create Date: 2024-10-31 09:56:43.335627 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '958df14798d5' -down_revision = '062a154a0797' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('teams', schema=None) as batch_op: - batch_op.add_column(sa.Column('discord_webhook_url', sa.String(length=255), nullable=True)) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('teams', schema=None) as batch_op: - batch_op.drop_column('discord_webhook_url') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/a340b3da0f2a_add_auth_session_key.py b/backend-flask/migrations/versions/a340b3da0f2a_add_auth_session_key.py deleted file mode 100644 index 33c3459..0000000 --- a/backend-flask/migrations/versions/a340b3da0f2a_add_auth_session_key.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add auth_session.key - -Revision ID: a340b3da0f2a -Revises: 273f73c81783 -Create Date: 2024-10-29 23:17:29.296293 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'a340b3da0f2a' -down_revision = '273f73c81783' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('auth_session', schema=None) as batch_op: - batch_op.add_column(sa.Column('key', sa.String(length=31), nullable=False)) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('auth_session', schema=None) as batch_op: - batch_op.drop_column('key') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/b00632365b58_.py b/backend-flask/migrations/versions/b00632365b58_.py deleted file mode 100644 index cf9ceef..0000000 --- a/backend-flask/migrations/versions/b00632365b58_.py +++ /dev/null @@ -1,42 +0,0 @@ -"""empty message - -Revision ID: b00632365b58 -Revises: a340b3da0f2a -Create Date: 2024-10-29 23:27:37.306568 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'b00632365b58' -down_revision = 'a340b3da0f2a' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('auth_sessions', - sa.Column('key', sa.String(length=31), nullable=False), - sa.Column('player_id', sa.BigInteger(), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), - sa.PrimaryKeyConstraint('key') - ) - op.drop_table('auth_session') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('auth_session', - sa.Column('player_id', sa.BIGINT(), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.Column('key', sa.VARCHAR(length=31), nullable=False), - sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), - sa.PrimaryKeyConstraint('player_id') - ) - op.drop_table('auth_sessions') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/c242e3f99c64_add_webhook_profile_picture.py b/backend-flask/migrations/versions/c242e3f99c64_add_webhook_profile_picture.py deleted file mode 100644 index 1e93c0e..0000000 --- a/backend-flask/migrations/versions/c242e3f99c64_add_webhook_profile_picture.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add webhook profile picture - -Revision ID: c242e3f99c64 -Revises: 286ee26b9e5d -Create Date: 2024-11-27 10:40:39.027786 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'c242e3f99c64' -down_revision = '286ee26b9e5d' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('team_discord_integrations', schema=None) as batch_op: - batch_op.add_column(sa.Column('webhook_bot_profile_picture', sa.String(), nullable=True)) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('team_discord_integrations', schema=None) as batch_op: - batch_op.drop_column('webhook_bot_profile_picture') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/ce676db8c655_initial_migration.py b/backend-flask/migrations/versions/ce676db8c655_initial_migration.py deleted file mode 100644 index d3b3601..0000000 --- a/backend-flask/migrations/versions/ce676db8c655_initial_migration.py +++ /dev/null @@ -1,61 +0,0 @@ -"""Initial migration - -Revision ID: ce676db8c655 -Revises: -Create Date: 2024-10-28 17:42:13.639729 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ce676db8c655' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('players', - sa.Column('steam_id', sa.BigInteger(), nullable=False), - sa.Column('username', sa.String(length=63), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.PrimaryKeyConstraint('steam_id') - ) - op.create_table('teams', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('team_name', sa.String(length=63), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('team_name') - ) - op.create_table('players_teams', - sa.Column('player_id', sa.BigInteger(), nullable=False), - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('team_role', sa.Enum('Player', 'CoachMentor', name='teamrole'), nullable=False), - sa.Column('playtime', sa.Interval(), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.ForeignKeyConstraint(['player_id'], ['players.steam_id'], ), - sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ), - sa.PrimaryKeyConstraint('player_id', 'team_id') - ) - op.create_table('players_teams_roles', - sa.Column('player_id', sa.Integer(), nullable=False), - sa.Column('team_id', sa.Integer(), nullable=False), - sa.Column('role', sa.Enum('Unknown', 'Scout', 'PocketScout', 'FlankScout', 'Soldier', 'PocketSoldier', 'Roamer', 'Pyro', 'Demoman', 'HeavyWeapons', 'Engineer', 'Medic', 'Sniper', 'Spy', name='role'), nullable=False), - sa.Column('is_main', sa.Boolean(), nullable=False), - sa.ForeignKeyConstraint(['player_id', 'team_id'], ['players_teams.player_id', 'players_teams.team_id'], ), - sa.PrimaryKeyConstraint('player_id', 'team_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('players_teams_roles') - op.drop_table('players_teams') - op.drop_table('teams') - op.drop_table('players') - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/d15570037f47_change_intervals_to_integers.py b/backend-flask/migrations/versions/d15570037f47_change_intervals_to_integers.py deleted file mode 100644 index fac8ddc..0000000 --- a/backend-flask/migrations/versions/d15570037f47_change_intervals_to_integers.py +++ /dev/null @@ -1,50 +0,0 @@ -"""Change intervals to integers - -Revision ID: d15570037f47 -Revises: 7995474ef2cc -Create Date: 2024-12-09 20:16:18.385467 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'd15570037f47' -down_revision = '7995474ef2cc' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('matches', schema=None) as batch_op: - batch_op.alter_column('duration', - existing_type=sa.DATETIME(), - type_=sa.Integer(), - existing_nullable=False) - - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.alter_column('playtime', - existing_type=sa.DATETIME(), - type_=sa.Integer(), - existing_nullable=False) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.alter_column('playtime', - existing_type=sa.Integer(), - type_=sa.DATETIME(), - existing_nullable=False) - - with op.batch_alter_table('matches', schema=None) as batch_op: - batch_op.alter_column('duration', - existing_type=sa.Integer(), - type_=sa.DATETIME(), - existing_nullable=False) - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py b/backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py deleted file mode 100644 index ee56a3e..0000000 --- a/backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py +++ /dev/null @@ -1,38 +0,0 @@ -"""Add has_confirmed column - -Revision ID: dcf5ffd0ec73 -Revises: 2a33f577d655 -Create Date: 2024-11-25 09:17:26.892047 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'dcf5ffd0ec73' -down_revision = '2a33f577d655' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_events', schema=None) as batch_op: - batch_op.add_column(sa.Column('has_confirmed', sa.Boolean(), nullable=False)) - batch_op.alter_column('player_team_role_id', - existing_type=sa.INTEGER(), - nullable=True) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_events', schema=None) as batch_op: - batch_op.alter_column('player_team_role_id', - existing_type=sa.INTEGER(), - nullable=False) - batch_op.drop_column('has_confirmed') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/ea359b0e46d7_add_team_tz_timezone.py b/backend-flask/migrations/versions/ea359b0e46d7_add_team_tz_timezone.py deleted file mode 100644 index 30a6efb..0000000 --- a/backend-flask/migrations/versions/ea359b0e46d7_add_team_tz_timezone.py +++ /dev/null @@ -1,55 +0,0 @@ -"""Add Team.tz_timezone - -Revision ID: ea359b0e46d7 -Revises: 2b2f3ae2ec7f -Create Date: 2024-11-03 16:53:37.904012 - -""" -from alembic import op -import sqlalchemy as sa -import sqlalchemy_utc - - -# revision identifiers, used by Alembic. -revision = 'ea359b0e46d7' -down_revision = '2b2f3ae2ec7f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.alter_column('start_time', - existing_type=sa.TIMESTAMP(), - type_=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), - existing_nullable=False) - batch_op.alter_column('end_time', - existing_type=sa.TIMESTAMP(), - type_=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), - existing_nullable=False) - - with op.batch_alter_table('teams', schema=None) as batch_op: - batch_op.add_column(sa.Column('tz_timezone', sa.String(length=31), nullable=False, default='Etc/UTC', server_default='0')) - batch_op.add_column(sa.Column('minute_offset', sa.SmallInteger(), nullable=False, default=0, server_default='0')) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('teams', schema=None) as batch_op: - batch_op.drop_column('minute_offset') - batch_op.drop_column('tz_timezone') - - with op.batch_alter_table('players_teams_availability', schema=None) as batch_op: - batch_op.alter_column('end_time', - existing_type=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), - type_=sa.TIMESTAMP(), - existing_nullable=False) - batch_op.alter_column('start_time', - existing_type=sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), - type_=sa.TIMESTAMP(), - existing_nullable=False) - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/f50a79c4ae22_add_playerteam_is_team_leader.py b/backend-flask/migrations/versions/f50a79c4ae22_add_playerteam_is_team_leader.py deleted file mode 100644 index 0985c71..0000000 --- a/backend-flask/migrations/versions/f50a79c4ae22_add_playerteam_is_team_leader.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Add PlayerTeam.is_team_leader - -Revision ID: f50a79c4ae22 -Revises: ea359b0e46d7 -Create Date: 2024-11-03 17:11:35.956743 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'f50a79c4ae22' -down_revision = 'ea359b0e46d7' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.add_column(sa.Column('is_team_leader', sa.Boolean(), nullable=False, server_default='0')) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('players_teams', schema=None) as batch_op: - batch_op.drop_column('is_team_leader') - - # ### end Alembic commands ### diff --git a/backend-flask/migrations/versions/f802d763a7b4_drop_integrations_tables.py b/backend-flask/migrations/versions/f802d763a7b4_drop_integrations_tables.py deleted file mode 100644 index b8fe1f2..0000000 --- a/backend-flask/migrations/versions/f802d763a7b4_drop_integrations_tables.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Drop integrations tables - -Revision ID: f802d763a7b4 -Revises: dcf5ffd0ec73 -Create Date: 2024-11-25 18:34:08.136071 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'f802d763a7b4' -down_revision = 'dcf5ffd0ec73' -branch_labels = None -depends_on = None - - -def upgrade(): - # drop integrations tables - op.drop_table("team_discord_integrations") - op.drop_table("team_logs_tf_integrations") - op.drop_table("team_integrations") - pass - - -def downgrade(): - pass diff --git a/backend-flask/migrations/versions/fda727438444_add_match_table.py b/backend-flask/migrations/versions/fda727438444_add_match_table.py deleted file mode 100644 index 5ba74d3..0000000 --- a/backend-flask/migrations/versions/fda727438444_add_match_table.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Add match table - -Revision ID: fda727438444 -Revises: c242e3f99c64 -Create Date: 2024-12-09 12:45:16.974122 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'fda727438444' -down_revision = 'c242e3f99c64' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('matches', - sa.Column('logs_tf_id', sa.Integer(), nullable=False), - sa.Column('logs_tf_title', sa.String(length=255), nullable=False), - sa.Column('duration', sa.Interval(), nullable=False), - sa.Column('match_time', sa.TIMESTAMP(), nullable=False), - sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), - sa.PrimaryKeyConstraint('logs_tf_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('matches') - # ### end Alembic commands ###