mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 20:40:13 +03:00
Complete fix: delete resource records when deleting resource pool
This completes the fix from PR #2315 by ensuring that when a resource pool is deleted, all associated resource records are also deleted from the resources table, preventing orphaned resource records. Changes: - Modified delete_resource_pool() to first delete all resource records in the pool before deleting the pool itself - This complements the existing fix in remove_resource_from_pool() which handles single resource removal
This commit is contained in:
parent
fcb76a4b01
commit
d2848a600e
@ -156,6 +156,14 @@ class ResourcePoolsRepository(BaseRepository):
|
||||
Delete a resource pool.
|
||||
"""
|
||||
|
||||
# Get all resources in the pool first
|
||||
resources = await self.get_pool_resources(resource_pool_id)
|
||||
|
||||
# Delete all resource records
|
||||
for resource in resources:
|
||||
await self.delete_resource(resource.resource_id)
|
||||
|
||||
# Now delete the resource pool
|
||||
query = delete(models.ResourcePool).where(models.ResourcePool.resource_pool_id == resource_pool_id)
|
||||
result = await self._db_session.execute(query)
|
||||
await self._db_session.commit()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user