diff --git a/packages/api-server/api_server/models/building_map.py b/packages/api-server/api_server/models/building_map.py index f92fbad81..7525dcc28 100644 --- a/packages/api-server/api_server/models/building_map.py +++ b/packages/api-server/api_server/models/building_map.py @@ -20,4 +20,8 @@ def from_tortoise(tortoise: ttm.BuildingMap) -> "BuildingMap": return BuildingMap(**tortoise.data) async def save(self) -> None: + existing_maps = await ttm.BuildingMap.all() + for m in existing_maps: + if m.id_ != self.name: + await m.delete() await ttm.BuildingMap.update_or_create({"data": self.dict()}, id_=self.name)