From 67ef999017d6a925439e2270cf29132b655b65f3 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Mon, 25 Nov 2024 11:35:39 -0800 Subject: [PATCH] Add player_event.has_confirmed --- .../dcf5ffd0ec73_add_has_confirmed_column.py | 38 +++++++++++++++++++ backend-flask/models/player_event.py | 4 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py diff --git a/backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py b/backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py new file mode 100644 index 0000000..ee56a3e --- /dev/null +++ b/backend-flask/migrations/versions/dcf5ffd0ec73_add_has_confirmed_column.py @@ -0,0 +1,38 @@ +"""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/models/player_event.py b/backend-flask/models/player_event.py index db0d802..cbb21ac 100644 --- a/backend-flask/models/player_event.py +++ b/backend-flask/models/player_event.py @@ -1,6 +1,7 @@ from sqlalchemy.orm import mapped_column, relationship from sqlalchemy.orm.attributes import Mapped from sqlalchemy.orm.properties import ForeignKey +from sqlalchemy.types import Boolean import app_db @@ -9,7 +10,8 @@ class PlayerEvent(app_db.BaseModel): event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), primary_key=True) player_id: Mapped[int] = mapped_column(ForeignKey("players.steam_id"), primary_key=True) - player_team_role_id: Mapped[int] = mapped_column(ForeignKey("players_teams_roles.id")) + player_team_role_id: Mapped[int] = mapped_column(ForeignKey("players_teams_roles.id"), nullable=True) + has_confirmed: Mapped[bool] = mapped_column(Boolean, default=False) event: Mapped["Event"] = relationship("Event", back_populates="players") player: Mapped["Player"] = relationship("Player", back_populates="events")