mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: migrate orgconfig to 1.1
This commit is contained in:
parent
1423e4c432
commit
b425f3a6bd
5 changed files with 51 additions and 1 deletions
|
|
@ -2,6 +2,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 src.core.events.database import get_db_session
|
||||
from src.db.organization_config import OrganizationConfig
|
||||
|
||||
|
|
@ -32,3 +33,22 @@ async def migrate(
|
|||
db_session.commit()
|
||||
|
||||
return {"message": "Migration successful"}
|
||||
|
||||
|
||||
@router.post("/migrate_orgconfig_v1_to_v1.1")
|
||||
async def migratev1_1(
|
||||
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_1(orgConfig.config)
|
||||
|
||||
db_session.add(orgConfig)
|
||||
db_session.commit()
|
||||
|
||||
return {"message": "Migration successful"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue