From 75efb88a66fc365bf2ef8a0babc203f879275bcd Mon Sep 17 00:00:00 2001 From: Vin Bui Date: Tue, 16 Apr 2024 01:15:33 -0400 Subject: [PATCH] Fix amentity duplication issue --- src/utils/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/utils.py b/src/utils/utils.py index 0b8ff48..aeaa92b 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -103,6 +103,9 @@ def create_gym_table(): amenity["type"] = AmenityType[amenity["type"]] amenities.append(Amenity(**amenity)) + # Clear amenities to prevent duplication + db_session.query(Amenity).delete() + # Add to database [db_session.merge(gym) for gym in gyms] [db_session.merge(facility) for facility in facilities]