File: migrateschema.py

package info (click to toggle)
python-django-pgschemas 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 848 kB
  • sloc: python: 3,887; makefile: 33; sh: 10; sql: 2
file content (32 lines) | stat: -rw-r--r-- 1,036 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
21
22
23
24
25
26
27
28
29
30
31
32
from django.core.checks import Tags, run_checks
from django.core.management.base import BaseCommand
from django.core.management.commands.migrate import Command as MigrateCommand

from . import WrappedSchemaOption
from .runschema import Command as RunSchemaCommand


class NonInteractiveRunSchemaCommand(RunSchemaCommand):
    allow_interactive = False


class MigrateSchemaCommand(WrappedSchemaOption, BaseCommand):
    allow_interactive = False
    requires_system_checks = []

    def _run_checks(self, **kwargs):  # pragma: no cover
        issues = run_checks(tags=[Tags.database])
        issues.extend(super()._run_checks(**kwargs))
        return issues

    def add_arguments(self, parser):
        super().add_arguments(parser)
        MigrateCommand.add_arguments(self, parser)

    def handle(self, *args, **options):
        runschema = NonInteractiveRunSchemaCommand()
        options.pop("run_syncdb", False)
        runschema.execute(command_name="django.core.migrate", *args, **options)


Command = MigrateSchemaCommand