fix: add event handler to delete the site when the related app deleted (#5282)

This commit is contained in:
kurokobo 2024-06-17 09:47:26 +09:00 committed by GitHub
parent 4f60fe7bc6
commit 42029791e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,7 @@ from .create_installed_app_when_app_created import handle
from .create_site_record_when_app_created import handle
from .deduct_quota_when_messaeg_created import handle
from .delete_installed_app_when_app_deleted import handle
from .delete_site_record_when_app_deleted import handle
from .delete_tool_parameters_cache_when_sync_draft_workflow import handle
from .delete_workflow_as_tool_when_app_deleted import handle
from .update_app_dataset_join_when_app_model_config_updated import handle

View File

@ -0,0 +1,11 @@
from events.app_event import app_was_deleted
from extensions.ext_database import db
from models.model import Site
@app_was_deleted.connect
def handle(sender, **kwargs):
app = sender
site = db.session.query(Site).filter(Site.app_id == app.id).first()
db.session.delete(site)
db.session.commit()