-
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.
- Loading branch information
Парфенов Михаил Александрович
committed
Nov 30, 2024
1 parent
536ff2d
commit c498fed
Showing
3 changed files
with
159 additions
and
6 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
migrations/versions/20241130_1731_91cf4b4d68eb_drop_ods_timetable.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,72 @@ | ||
"""drop_ods_timetable | ||
Revision ID: 91cf4b4d68eb | ||
Revises: b9023536db5b | ||
Create Date: 2024-11-30 17:31:15.017281 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import os | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '91cf4b4d68eb' | ||
down_revision = 'b9023536db5b' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.drop_index( | ||
'ix_ODS_TIMETABLE_ods_timetable_act_event_text', table_name='ods_timetable_act', schema='ODS_TIMETABLE' | ||
) | ||
op.revoke_on_table( | ||
"test_dwh_ods_timetable_read" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_read", | ||
['SELECT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.revoke_on_table( | ||
"test_dwh_ods_timetable_write" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_write", | ||
['SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'INSERT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.revoke_on_table( | ||
"test_dwh_ods_timetable_all" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_all", | ||
['ALL'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.drop_table('ods_timetable_act', schema='ODS_TIMETABLE') | ||
|
||
|
||
def downgrade(): | ||
op.create_table( | ||
'ods_timetable_act', | ||
sa.Column('event_text', sa.VARCHAR(), autoincrement=False, nullable=True), | ||
sa.Column('time_interval_text', sa.VARCHAR(), autoincrement=False, nullable=True), | ||
sa.Column('group_text', sa.VARCHAR(), autoincrement=False, nullable=True), | ||
schema='ODS_TIMETABLE', | ||
) | ||
op.grant_on_table( | ||
"test_dwh_ods_timetable_all" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_all", | ||
['ALL'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.grant_on_table( | ||
"test_dwh_ods_timetable_write" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_write", | ||
['SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'INSERT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.grant_on_table( | ||
"test_dwh_ods_timetable_read" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_read", | ||
['SELECT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.create_index( | ||
'ix_ODS_TIMETABLE_ods_timetable_act_event_text', | ||
'ods_timetable_act', | ||
['event_text'], | ||
unique=False, | ||
schema='ODS_TIMETABLE', | ||
) |
74 changes: 74 additions & 0 deletions
74
migrations/versions/20241130_1742_09416a9fa7cc_add_ods_timetable.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,74 @@ | ||
"""add_ods_timetable | ||
Revision ID: 09416a9fa7cc | ||
Revises: 91cf4b4d68eb | ||
Create Date: 2024-11-30 17:42:06.544423 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import os | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '09416a9fa7cc' | ||
down_revision = '91cf4b4d68eb' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'ods_timetable_act', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(), nullable=False, comment='Название события'), | ||
sa.Column('odd', sa.Boolean(), nullable=False, comment='Флаг: событие относится к нечетной неделе'), | ||
sa.Column('even', sa.Boolean(), nullable=False, comment='Флаг: событие относится к четной неделе'), | ||
sa.Column('weekday', sa.Integer(), nullable=False, comment='Номер недели'), | ||
sa.Column('num', sa.Integer(), nullable=False, comment='Номер события'), | ||
sa.Column('start', sa.String(), nullable=False, comment='Время начала события (в строке)'), | ||
sa.Column('end', sa.String(), nullable=False, comment='Время конца события (в строке)'), | ||
sa.Column('group', sa.String(), nullable=False, comment='Академическая группа, к которой относится событие'), | ||
sa.PrimaryKeyConstraint('id'), | ||
schema='ODS_TIMETABLE', | ||
comment='\n Таблица содержит десериализованные события с сайта ras.phys.msu\n Выделяется блок текста из общей таблицы, нужна для обновления расписания в приложении ТвойФФ\n ', | ||
) | ||
op.create_index( | ||
op.f('ix_ODS_TIMETABLE_ods_timetable_act_id'), 'ods_timetable_act', ['id'], unique=False, schema='ODS_TIMETABLE' | ||
) | ||
op.grant_on_table( | ||
"test_dwh_ods_timetable_read" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_read", | ||
['SELECT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.grant_on_table( | ||
"test_dwh_ods_timetable_write" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_write", | ||
['SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'INSERT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.grant_on_table( | ||
"test_dwh_ods_timetable_all" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_all", | ||
['ALL'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.revoke_on_table( | ||
"test_dwh_ods_timetable_all" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_all", | ||
['ALL'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.revoke_on_table( | ||
"test_dwh_ods_timetable_write" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_write", | ||
['SELECT', 'UPDATE', 'DELETE', 'TRUNCATE', 'INSERT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.revoke_on_table( | ||
"test_dwh_ods_timetable_read" if os.getenv("ENVIRONMENT") != "production" else "prod_dwh_ods_timetable_read", | ||
['SELECT'], | ||
'"ODS_TIMETABLE".ods_timetable_act', | ||
) | ||
op.drop_index(op.f('ix_ODS_TIMETABLE_ods_timetable_act_id'), table_name='ods_timetable_act', schema='ODS_TIMETABLE') | ||
op.drop_table('ods_timetable_act', schema='ODS_TIMETABLE') |
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