Allow passing '--sql-analyser' to makemigrations command
This commit is contained in:
1 parent
c7d9129db9
commit
c2ad3e6aeb
4 files changed
+15
-10
No files matched your search
+4
-3
@@ -1,7 +1,8 @@
|
|||||||
## 4.x.y (unreleased)
|
## 4.1.0 (unreleased)
|
||||||
|
|
||||||
- Allow configuring logging for `makemigrations` command and unify behaviour with `lintmigrations`
|
- Allow configuring logging for `makemigrations` command and unify behaviour with `lintmigrations` (issue #207)
|
||||||
- Adapt `--warnings-as-errors` option to allow selecting some migration tests only
|
- Adapt `--warnings-as-errors` option to allow selecting some migration tests only (issue #201)
|
||||||
|
- Add `sql_analyser` option to `makemigrations` in order to specify the SQL analyser to use (issue #208)
|
||||||
|
|
||||||
## 4.0.0
|
## 4.0.0
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ from django.core.management.base import BaseCommand
|
|||||||
|
|
||||||
from ...constants import __version__
|
from ...constants import __version__
|
||||||
from ...migration_linter import MessageType, MigrationLinter
|
from ...migration_linter import MessageType, MigrationLinter
|
||||||
from ...sql_analyser.analyser import ANALYSER_STRING_MAPPING
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
configure_logging,
|
configure_logging,
|
||||||
extract_warnings_as_errors_option,
|
extract_warnings_as_errors_option,
|
||||||
@@ -130,12 +129,6 @@ class Command(BaseCommand):
|
|||||||
choices=MessageType.values(),
|
choices=MessageType.values(),
|
||||||
help="don't print linting messages to stdout",
|
help="don't print linting messages to stdout",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--sql-analyser",
|
|
||||||
nargs="?",
|
|
||||||
choices=list(ANALYSER_STRING_MAPPING.keys()),
|
|
||||||
help="select the SQL analyser",
|
|
||||||
)
|
|
||||||
register_linting_configuration_options(parser)
|
register_linting_configuration_options(parser)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class Command(MakeMigrationsCommand):
|
|||||||
self.database = options["database"]
|
self.database = options["database"]
|
||||||
self.exclude_migrations_tests = options["exclude_migration_tests"]
|
self.exclude_migrations_tests = options["exclude_migration_tests"]
|
||||||
self.warnings_as_errors = options["warnings_as_errors"]
|
self.warnings_as_errors = options["warnings_as_errors"]
|
||||||
|
self.sql_analyser = options["sql_analyser"]
|
||||||
configure_logging(options["verbosity"])
|
configure_logging(options["verbosity"])
|
||||||
return super(Command, self).handle(*app_labels, **options)
|
return super(Command, self).handle(*app_labels, **options)
|
||||||
|
|
||||||
@@ -85,6 +86,7 @@ class Command(MakeMigrationsCommand):
|
|||||||
exclude_migration_tests=self.exclude_migrations_tests,
|
exclude_migration_tests=self.exclude_migrations_tests,
|
||||||
warnings_as_errors_tests=warnings_as_errors_tests,
|
warnings_as_errors_tests=warnings_as_errors_tests,
|
||||||
all_warnings_as_errors=all_warnings_as_errors,
|
all_warnings_as_errors=all_warnings_as_errors,
|
||||||
|
analyser_string=self.sql_analyser,
|
||||||
)
|
)
|
||||||
|
|
||||||
for app_label, app_migrations in changes.items():
|
for app_label, app_migrations in changes.items():
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from ..sql_analyser.analyser import ANALYSER_STRING_MAPPING
|
||||||
|
|
||||||
|
|
||||||
def register_linting_configuration_options(parser):
|
def register_linting_configuration_options(parser):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -27,6 +29,13 @@ def register_linting_configuration_options(parser):
|
|||||||
"errors (e.g. RUNPYTHON_REVERSIBLE)",
|
"errors (e.g. RUNPYTHON_REVERSIBLE)",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--sql-analyser",
|
||||||
|
nargs="?",
|
||||||
|
choices=list(ANALYSER_STRING_MAPPING.keys()),
|
||||||
|
help="select the SQL analyser",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def configure_logging(verbosity):
|
def configure_logging(verbosity):
|
||||||
logger = logging.getLogger("django_migration_linter")
|
logger = logging.getLogger("django_migration_linter")
|
||||||
|
|||||||
Reference in new issue
Block a user