Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #116

Merged
merged 1 commit into from
Dec 12, 2024
Merged

fixes #116

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions migrations/versions/20241212_1543_f62898bb3315_uids_to_dims.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""uids_to_dims

Check failure on line 1 in migrations/versions/20241212_1543_f62898bb3315_uids_to_dims.py

View workflow job for this annotation

GitHub Actions / linting

Imports are incorrectly sorted and/or formatted.

Revision ID: f62898bb3315
Revises: 0d462525c992
Create Date: 2024-12-12 15:43:14.642986

"""

from alembic import op
import sqlalchemy as sa
import os


# revision identifiers, used by Alembic.
revision = 'f62898bb3315'
down_revision = '0d462525c992'
branch_labels = None
depends_on = None


def upgrade():
# alembic cannot do it properly, so you need to manually handle columns
# dim_event_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_event_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_event_act add COLUMN IF not EXISTS id UUID')
# dim_group_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_group_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_group_act add COLUMN IF not EXISTS id UUID')
# dim_lecturer_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_lecturer_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_lecturer_act add COLUMN IF not EXISTS id UUID')
# dim_room_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_room_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_room_act add COLUMN IF not EXISTS id UUID')
op.drop_column('ods_link_timetable_group', 'lesson_id', schema='ODS_TIMETABLE')


def downgrade():
op.add_column(
'ods_link_timetable_group',
sa.Column('lesson_id', sa.INTEGER(), autoincrement=False, nullable=True),
schema='ODS_TIMETABLE',
)
# alembic cannot do it properly, so you need to manually handle columns
# dim_event_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_event_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_event_act add COLUMN IF not EXISTS id INTEGER')
# dim_group_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_group_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_group_act add COLUMN IF not EXISTS id INTEGER')
# dim_lecturer_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_lecturer_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_lecturer_act add COLUMN IF not EXISTS id INTEGER')
# dim_room_act
op.execute('ALTER TABLE "DM_TIMETABLE".dim_room_act drop COLUMN IF EXISTS id')
op.execute('ALTER TABLE "DM_TIMETABLE".dim_room_act add COLUMN IF not EXISTS id INTEGER')
12 changes: 8 additions & 4 deletions profcomff_definitions/DM/timetable.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

import uuid

from sqlalchemy import UUID, String
from sqlalchemy.orm import Mapped, mapped_column

from profcomff_definitions.base import Base


class DimRoomAct(Base):
id: Mapped[int] = mapped_column(primary_key=True)
id: Mapped[uuid.UUID] = mapped_column(UUID, primary_key=True, default=uuid.uuid4)
room_api_id: Mapped[int]
room_name: Mapped[str | None]
room_direction_text_type: Mapped[str | None]
Expand All @@ -13,7 +17,7 @@ class DimRoomAct(Base):


class DimLecturerAct(Base):
id: Mapped[int] = mapped_column(primary_key=True)
id: Mapped[uuid.UUID] = mapped_column(UUID, primary_key=True, default=uuid.uuid4)
lecturer_api_id: Mapped[int]
lecturer_first_name: Mapped[str | None]
lecturer_middle_name: Mapped[str | None]
Expand All @@ -24,15 +28,15 @@ class DimLecturerAct(Base):


class DimGroupAct(Base):
id: Mapped[int] = mapped_column(primary_key=True)
id: Mapped[uuid.UUID] = mapped_column(UUID, primary_key=True, default=uuid.uuid4)
group_api_id: Mapped[int]
group_name_text: Mapped[str | None]
group_number: Mapped[str | None]
source_name: Mapped[str]


class DimEventAct(Base):
id: Mapped[int] = mapped_column(primary_key=True)
id: Mapped[uuid.UUID] = mapped_column(UUID, primary_key=True, default=uuid.uuid4)
event_api_id: Mapped[int | None]
event_name_text: Mapped[str | None]
source_name: Mapped[str]
Loading