File: apps.py

package info (click to toggle)
python-django-pgtrigger 4.15.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 956 kB
  • sloc: python: 4,412; makefile: 114; sh: 8; sql: 2
file content (20 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import django.apps
from django.db import connections
from django.db.models.signals import pre_migrate


def install_schemas(using, **kwargs):
    if connections[using].vendor == "postgresql":
        with connections[using].cursor() as cursor:
            cursor.execute('CREATE SCHEMA IF NOT EXISTS "order";')
            cursor.execute("CREATE SCHEMA IF NOT EXISTS receipt;")


class PGTriggerTestsConfig(django.apps.AppConfig):
    name = "pgtrigger.tests"

    def ready(self):
        """
        Ensure schemas are created for test databases before migrations
        """
        pre_migrate.connect(install_schemas, sender=self)