diff --git a/src/agenda_culturel/migrations/0099_update_categories.py b/src/agenda_culturel/migrations/0099_update_categories.py index f6cb4f2..ef99df5 100644 --- a/src/agenda_culturel/migrations/0099_update_categories.py +++ b/src/agenda_culturel/migrations/0099_update_categories.py @@ -87,9 +87,13 @@ new_cats = [ def create_categories(apps, catlist): Category = apps.get_model("agenda_culturel", "Category") - cats = [Category(name=c.name, color=c.color, position=c.position, pictogram=c.get_pictogram_file()) for c in catlist] + # only create new categories if old ones are present to avoid filling + # an empty database with ghost categories + if Category.objects.count() > 1: - Category.objects.bulk_create(cats) + cats = [Category(name=c.name, color=c.color, position=c.position, pictogram=c.get_pictogram_file()) for c in catlist] + + Category.objects.bulk_create(cats)