mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: create and delete assignment activities from UI
This commit is contained in:
parent
04c05e4f9a
commit
10e9be1d33
14 changed files with 358 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import importlib
|
||||
from logging.config import fileConfig
|
||||
import os
|
||||
|
||||
import alembic_postgresql_enum
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
from sqlmodel import SQLModel
|
||||
|
|
|
|||
41
apps/api/migrations/versions/6295e05ff7d0_enum_updates.py
Normal file
41
apps/api/migrations/versions/6295e05ff7d0_enum_updates.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
"""Enum updates
|
||||
|
||||
Revision ID: 6295e05ff7d0
|
||||
Revises: df2981bf24dd
|
||||
Create Date: 2024-07-11 20:46:26.582170
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
from alembic_postgresql_enum import TableReference # type: ignore
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '6295e05ff7d0'
|
||||
down_revision: Union[str, None] = 'df2981bf24dd'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.sync_enum_values('public', 'activitytypeenum', ['TYPE_VIDEO', 'TYPE_DOCUMENT', 'TYPE_DYNAMIC', 'TYPE_ASSIGNMENT', 'TYPE_CUSTOM'],
|
||||
[TableReference(table_schema='public', table_name='activity', column_name='activity_type')],
|
||||
enum_values_to_rename=[])
|
||||
op.sync_enum_values('public', 'activitysubtypeenum', ['SUBTYPE_DYNAMIC_PAGE', 'SUBTYPE_VIDEO_YOUTUBE', 'SUBTYPE_VIDEO_HOSTED', 'SUBTYPE_DOCUMENT_PDF', 'SUBTYPE_DOCUMENT_DOC', 'SUBTYPE_ASSIGNMENT_ANY', 'SUBTYPE_CUSTOM'],
|
||||
[TableReference(table_schema='public', table_name='activity', column_name='activity_sub_type')],
|
||||
enum_values_to_rename=[])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.sync_enum_values('public', 'activitysubtypeenum', ['SUBTYPE_DYNAMIC_PAGE', 'SUBTYPE_VIDEO_YOUTUBE', 'SUBTYPE_VIDEO_HOSTED', 'SUBTYPE_DOCUMENT_PDF', 'SUBTYPE_DOCUMENT_DOC', 'SUBTYPE_ASSESSMENT_QUIZ', 'SUBTYPE_CUSTOM'],
|
||||
[TableReference(table_schema='public', table_name='activity', column_name='activity_sub_type')],
|
||||
enum_values_to_rename=[])
|
||||
op.sync_enum_values('public', 'activitytypeenum', ['TYPE_VIDEO', 'TYPE_DOCUMENT', 'TYPE_DYNAMIC', 'TYPE_ASSESSMENT', 'TYPE_CUSTOM'],
|
||||
[TableReference(table_schema='public', table_name='activity', column_name='activity_type')],
|
||||
enum_values_to_rename=[])
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -23,6 +23,9 @@ depends_on: Union[str, Sequence[str], None] = None
|
|||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('activity', sa.Column('published', sa.Boolean(), nullable=False, server_default=sa.true()))
|
||||
# If you need to rename columns instead of dropping them, use the rename_column command
|
||||
# For example, if we are changing the name 'published_version' to 'published', we would use:
|
||||
# op.alter_column('activity', 'published_version', new_column_name='published', existing_type=sa.Boolean())
|
||||
op.drop_column('activity', 'published_version')
|
||||
op.drop_column('activity', 'version')
|
||||
|
||||
|
|
@ -32,7 +35,6 @@ def upgrade() -> None:
|
|||
op.create_foreign_key('trail_org_id_fkey', 'trail', 'organization', ['org_id'], ['id'], ondelete='CASCADE')
|
||||
op.drop_constraint('trail_user_id_fkey', 'trail', type_='foreignkey')
|
||||
op.create_foreign_key('trail_user_id_fkey', 'trail', 'user', ['user_id'], ['id'], ondelete='CASCADE')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
|
@ -45,7 +47,8 @@ def downgrade() -> None:
|
|||
|
||||
op.add_column('assignmentusersubmission', sa.Column('assignment_user_uuid', sa.VARCHAR(), autoincrement=False, nullable=False))
|
||||
|
||||
op.add_column('activity', sa.Column('version', sa.INTEGER(), autoincrement=False, nullable=False , server_default=sa.text('1')))
|
||||
op.add_column('activity', sa.Column('published_version', sa.INTEGER(), autoincrement=False, nullable=False , server_default=sa.text('1')) )
|
||||
op.add_column('activity', sa.Column('version', sa.INTEGER(), autoincrement=False, nullable=False, server_default=sa.text('1')))
|
||||
op.add_column('activity', sa.Column('published_version', sa.INTEGER(), autoincrement=False, nullable=False, server_default=sa.text('1')))
|
||||
op.drop_column('activity', 'published')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue