diff --git a/migrations/versions/20240830_1617_f9426dfd57e2_change_to_nullable_events_id.py b/migrations/versions/20240830_1617_f9426dfd57e2_change_to_nullable_events_id.py new file mode 100644 index 00000000..0a103d98 --- /dev/null +++ b/migrations/versions/20240830_1617_f9426dfd57e2_change_to_nullable_events_id.py @@ -0,0 +1,42 @@ +"""change to nullable events_id + +Revision ID: f9426dfd57e2 +Revises: eba63ac1dd15 +Create Date: 2024-08-30 16:17:30.062783 + +""" + +import os + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = 'f9426dfd57e2' +down_revision = 'eba63ac1dd15' +branch_labels = None +depends_on = None + + +def upgrade(): + op.alter_column( + 'diff', 'events_id', existing_type=postgresql.ARRAY(sa.INTEGER()), nullable=True, schema='STG_RASPHYSMSU' + ) + op.alter_column( + 'new', 'events_id', existing_type=postgresql.ARRAY(sa.INTEGER()), nullable=True, schema='STG_RASPHYSMSU' + ) + op.alter_column( + 'old', 'events_id', existing_type=postgresql.ARRAY(sa.INTEGER()), nullable=True, schema='STG_RASPHYSMSU' + ) + + +def downgrade(): + op.alter_column( + 'old', 'events_id', existing_type=postgresql.ARRAY(sa.INTEGER()), nullable=False, schema='STG_RASPHYSMSU' + ) + op.alter_column( + 'new', 'events_id', existing_type=postgresql.ARRAY(sa.INTEGER()), nullable=False, schema='STG_RASPHYSMSU' + ) + op.alter_column( + 'diff', 'events_id', existing_type=postgresql.ARRAY(sa.INTEGER()), nullable=False, schema='STG_RASPHYSMSU' + ) diff --git a/profcomff_definitions/STG/rasphysmsu.py b/profcomff_definitions/STG/rasphysmsu.py index debedcc5..54850323 100644 --- a/profcomff_definitions/STG/rasphysmsu.py +++ b/profcomff_definitions/STG/rasphysmsu.py @@ -28,7 +28,7 @@ class Diff(Base): place: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) group: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) teacher: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) - events_id: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) + events_id: Mapped[tp.List[int] | None] = mapped_column(ARRAY(Integer)) action: Mapped[str | None] @@ -44,7 +44,7 @@ class Old(Base): place: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) group: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) teacher: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) - events_id: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) + events_id: Mapped[tp.List[int] | None] = mapped_column(ARRAY(Integer)) class New(Base): @@ -59,4 +59,4 @@ class New(Base): place: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) group: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) teacher: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) - events_id: Mapped[tp.List[int]] = mapped_column(ARRAY(Integer)) + events_id: Mapped[tp.List[int] | None] = mapped_column(ARRAY(Integer))