From 9f781cae8d74e3ab117d345aa74d75ede1506c4c Mon Sep 17 00:00:00 2001 From: Dylan Leard Date: Fri, 14 Feb 2025 15:36:20 -0800 Subject: [PATCH] chore: skip load fixtures if data already exists --- bc_obps/common/management/commands/custom_migrate.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bc_obps/common/management/commands/custom_migrate.py b/bc_obps/common/management/commands/custom_migrate.py index b5dc8f0b93..20dfdbc9ad 100644 --- a/bc_obps/common/management/commands/custom_migrate.py +++ b/bc_obps/common/management/commands/custom_migrate.py @@ -4,6 +4,7 @@ from django.core.management import call_command from django.apps import apps from rls.utils.manager import RlsManager +from registration.models import Operation class Command(BaseCommand): @@ -18,6 +19,9 @@ def handle(self, *args, **options): # Revoke all RLS grants & policies for all roles # Re-apply all RLS grants & policies for all roles RlsManager.re_apply_rls() + if Operation.objects.exists(): + self.stdout.write(self.style.WARNING("Skipping fixture load: Data already exists.")) + return if os.environ.get('ENVIRONMENT') == 'test': call_command("pgtrigger", "disable", "--schema", "erc") call_command('load_test_data')