Skip to content

Commit

Permalink
bulk insert
Browse files Browse the repository at this point in the history
  • Loading branch information
parfenovma committed Aug 30, 2024
1 parent 55e350a commit 5846d5d
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
"""add_link_full_schema2
Revision ID: da280c5f1dac
Revises: eebd0dbc6839
Create Date: 2024-08-30 18:06:18.480250
"""

from alembic import op
import sqlalchemy as sa
import os
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'da280c5f1dac'
down_revision = 'eebd0dbc6839'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
'info',
'user_id',
existing_type=sa.VARCHAR(),
type_=sa.Integer(),
existing_nullable=False,
autoincrement=True,
schema='ODS_INFO',
)
op.add_column('raw_timetable_api', sa.Column('id', sa.Integer(), nullable=False), schema='STG_MYMSUAPI')
op.add_column('raw_timetable_api', sa.Column('discipline_name', sa.String(), nullable=False), schema='STG_MYMSUAPI')
op.alter_column(
'raw_timetable_api',
'group_name',
existing_type=sa.TEXT(),
type_=sa.String(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'discipline_id',
existing_type=sa.BIGINT(),
type_=sa.Integer(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'classroom_name',
existing_type=sa.TEXT(),
type_=sa.String(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'classroom_id',
existing_type=sa.BIGINT(),
type_=sa.Integer(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'lesson_type_text',
existing_type=sa.TEXT(),
type_=sa.String(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'lesson_from_dttm_ts',
existing_type=postgresql.TIMESTAMP(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'lesson_to_dttm_ts',
existing_type=postgresql.TIMESTAMP(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'teacher_users',
existing_type=sa.TEXT(),
type_=sa.JSON(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'study_groups',
existing_type=sa.TEXT(),
type_=sa.JSON(),
nullable=False,
schema='STG_MYMSUAPI',
)
op.drop_column('raw_timetable_api', 'dicscipline_name', schema='STG_MYMSUAPI')
op.alter_column(
'link_new_with_dates', 'subject', existing_type=sa.VARCHAR(), nullable=True, schema='STG_RASPHYSMSU'
)
op.alter_column('link_new_with_dates', 'odd', existing_type=sa.BOOLEAN(), nullable=True, schema='STG_RASPHYSMSU')
op.alter_column('link_new_with_dates', 'even', existing_type=sa.BOOLEAN(), nullable=True, schema='STG_RASPHYSMSU')
op.alter_column('link_new_with_dates', 'start', existing_type=sa.VARCHAR(), nullable=True, schema='STG_RASPHYSMSU')
op.alter_column('link_new_with_dates', 'end', existing_type=sa.VARCHAR(), nullable=True, schema='STG_RASPHYSMSU')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('link_new_with_dates', 'end', existing_type=sa.VARCHAR(), nullable=False, schema='STG_RASPHYSMSU')
op.alter_column('link_new_with_dates', 'start', existing_type=sa.VARCHAR(), nullable=False, schema='STG_RASPHYSMSU')
op.alter_column('link_new_with_dates', 'even', existing_type=sa.BOOLEAN(), nullable=False, schema='STG_RASPHYSMSU')
op.alter_column('link_new_with_dates', 'odd', existing_type=sa.BOOLEAN(), nullable=False, schema='STG_RASPHYSMSU')
op.alter_column(
'link_new_with_dates', 'subject', existing_type=sa.VARCHAR(), nullable=False, schema='STG_RASPHYSMSU'
)
op.add_column(
'raw_timetable_api',
sa.Column('dicscipline_name', sa.TEXT(), autoincrement=False, nullable=True),
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'study_groups',
existing_type=sa.JSON(),
type_=sa.TEXT(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'teacher_users',
existing_type=sa.JSON(),
type_=sa.TEXT(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'lesson_to_dttm_ts',
existing_type=postgresql.TIMESTAMP(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'lesson_from_dttm_ts',
existing_type=postgresql.TIMESTAMP(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'lesson_type_text',
existing_type=sa.String(),
type_=sa.TEXT(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'classroom_id',
existing_type=sa.Integer(),
type_=sa.BIGINT(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'classroom_name',
existing_type=sa.String(),
type_=sa.TEXT(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'discipline_id',
existing_type=sa.Integer(),
type_=sa.BIGINT(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.alter_column(
'raw_timetable_api',
'group_name',
existing_type=sa.String(),
type_=sa.TEXT(),
nullable=True,
schema='STG_MYMSUAPI',
)
op.drop_column('raw_timetable_api', 'discipline_name', schema='STG_MYMSUAPI')
op.drop_column('raw_timetable_api', 'id', schema='STG_MYMSUAPI')
op.alter_column(
'info',
'user_id',
existing_type=sa.Integer(),
type_=sa.VARCHAR(),
existing_nullable=False,
autoincrement=True,
schema='ODS_INFO',
)
# ### end Alembic commands ###
10 changes: 5 additions & 5 deletions profcomff_definitions/STG/rasphysmsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ class New(Base):

class LinkNewWithDates(Base):
id: Mapped[int] = mapped_column(primary_key=True)
subject: Mapped[str]
odd: Mapped[bool]
even: Mapped[bool]
subject: Mapped[str | None]
odd: Mapped[bool | None]
even: Mapped[bool | None]
weekday: Mapped[int | None]
num: Mapped[int | None]
start: Mapped[str]
end: Mapped[str]
start: Mapped[str | None]
end: Mapped[str | None]
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))
Expand Down

0 comments on commit 5846d5d

Please sign in to comment.