-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Парфенов Михаил Александрович <[email protected]>
- Loading branch information
1 parent
3df7c6e
commit 41d6a76
Showing
2 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
migrations/versions/20241212_1543_f62898bb3315_uids_to_dims.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""uids_to_dims | ||
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters