feat: implement cascading delete for gateway and associated installed skills
This commit is contained in:
committed by
Abhimanyu Saharan
parent
577c0d2839
commit
da6cc2544b
@@ -14,6 +14,7 @@ from app.db import crud
|
||||
from app.db.pagination import paginate
|
||||
from app.db.session import get_session
|
||||
from app.models.agents import Agent
|
||||
from app.models.gateway_installed_skills import GatewayInstalledSkill
|
||||
from app.models.gateways import Gateway
|
||||
from app.schemas.common import OkResponse
|
||||
from app.schemas.gateways import (
|
||||
@@ -175,6 +176,12 @@ async def delete_gateway(
|
||||
await service.clear_agent_foreign_keys(agent_id=agent.id)
|
||||
await session.delete(agent)
|
||||
|
||||
installed_skills = await GatewayInstalledSkill.objects.filter_by(
|
||||
gateway_id=gateway.id,
|
||||
).all(session)
|
||||
for installed_skill in installed_skills:
|
||||
await session.delete(installed_skill)
|
||||
|
||||
await session.delete(gateway)
|
||||
await session.commit()
|
||||
return OkResponse()
|
||||
|
||||
Reference in New Issue
Block a user