mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add orgconfig 1.2 migration
This commit is contained in:
parent
6d668006f8
commit
2e618d9c5a
3 changed files with 49 additions and 16 deletions
|
|
@ -1,8 +1,7 @@
|
|||
from fastapi import APIRouter, Depends
|
||||
from sqlmodel import Session, select
|
||||
from config.config import get_learnhouse_config
|
||||
from migrations.orgconfigs.v0tov1 import migrate_v0_to_v1
|
||||
from migrations.orgconfigs.v1_1 import migrate_to_v1_1
|
||||
from migrations.orgconfigs.orgconfigs_migrations import migrate_to_v1_1, migrate_to_v1_2, migrate_v0_to_v1
|
||||
from src.core.events.database import get_db_session
|
||||
from src.db.organization_config import OrganizationConfig
|
||||
|
||||
|
|
@ -51,4 +50,22 @@ async def migratev1_1(
|
|||
db_session.add(orgConfig)
|
||||
db_session.commit()
|
||||
|
||||
return {"message": "Migration successful"}
|
||||
|
||||
@router.post("/migrate_orgconfig_v1_to_v1.2")
|
||||
async def migratev1_2(
|
||||
db_session: Session = Depends(get_db_session),
|
||||
):
|
||||
"""
|
||||
Migrate organization config from v0 to v1
|
||||
"""
|
||||
statement = select(OrganizationConfig)
|
||||
result = db_session.exec(statement)
|
||||
|
||||
for orgConfig in result:
|
||||
orgConfig.config = migrate_to_v1_2(orgConfig.config)
|
||||
|
||||
db_session.add(orgConfig)
|
||||
db_session.commit()
|
||||
|
||||
return {"message": "Migration successful"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue