From 1fc262a53018765a8713c382bf7a15c99255331a Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 9 Jul 2023 21:20:09 +0800 Subject: [PATCH] Added custom_migrate command to simplify migrating with spatialite backend --- stude/accounts/management/__init__.py | 0 stude/accounts/management/commands/__init__.py | 0 .../accounts/management/commands/custom_migrate.py | 14 ++++++++++++++ 3 files changed, 14 insertions(+) create mode 100644 stude/accounts/management/__init__.py create mode 100644 stude/accounts/management/commands/__init__.py create mode 100644 stude/accounts/management/commands/custom_migrate.py diff --git a/stude/accounts/management/__init__.py b/stude/accounts/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stude/accounts/management/commands/__init__.py b/stude/accounts/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stude/accounts/management/commands/custom_migrate.py b/stude/accounts/management/commands/custom_migrate.py new file mode 100644 index 0000000..ad953c5 --- /dev/null +++ b/stude/accounts/management/commands/custom_migrate.py @@ -0,0 +1,14 @@ +from django.core.management.base import BaseCommand +from django.db import connection +from django.core.management import call_command + + +class Command(BaseCommand): + help = 'Run InitSpatialMetaData and then migrate' + + def handle(self, *args, **kwargs): + with connection.cursor() as cursor: + cursor.execute('SELECT InitSpatialMetaData(1);') + + # Call the Django migrate command + call_command('migrate')