diff --git a/django_migration_linter/__init__.py b/django_migration_linter/__init__.py index 959bac8..dd30599 100644 --- a/django_migration_linter/__init__.py +++ b/django_migration_linter/__init__.py @@ -13,3 +13,4 @@ # limitations under the License. from .migration_linter import * # noqa +from .constants import * # noqa diff --git a/django_migration_linter/constants.py b/django_migration_linter/constants.py new file mode 100644 index 0000000..b8356c6 --- /dev/null +++ b/django_migration_linter/constants.py @@ -0,0 +1,4 @@ +# Can be used to mark ignored migrations. +# This is a noop for SQL. Comments would be better. +# But comments are stripped by RunSQL +IGNORE_MIGRATION = ("SELECT 'dml-ignore'", ) diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index 139cbe6..e049ed5 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -24,11 +24,6 @@ from .sql_analyser import analyse_sql_statements logger = logging.getLogger(__name__) -# Can be used to mark ignored migrations. -# This is a noop for SQL. Comments would be better. -# But comments are stripped by RunSQL -IGNORE_MIGRATION = ("SELECT 'dml-ignore'", ) - class MigrationLinter(object): MIGRATION_FOLDER_NAME = 'migrations' diff --git a/django_migration_linter/sql_analyser.py b/django_migration_linter/sql_analyser.py index d07f544..edb655b 100644 --- a/django_migration_linter/sql_analyser.py +++ b/django_migration_linter/sql_analyser.py @@ -15,6 +15,8 @@ import re import logging +from django_migration_linter.constants import IGNORE_MIGRATION + logger = logging.getLogger(__name__) @@ -65,7 +67,7 @@ migration_tests = ( 'err_msg': '' }, { 'code': 'IGNORED_MIGRATION', - 'fn': lambda sql, **kw: re.search('dml-ignore', sql), + 'fn': lambda sql, **kw: re.search(IGNORE_MIGRATION[0], sql), 'err_msg': '', } )