simplify IgnoreMigration operation
This commit is contained in:
1 parent
758468cbb8
commit
dcaa52a4da
1 file changed
+3
-6
@@ -14,23 +14,20 @@
|
|||||||
|
|
||||||
from django.db.migrations.operations.base import Operation
|
from django.db.migrations.operations.base import Operation
|
||||||
|
|
||||||
IGNORE_MIGRATION_SQL = "select 1; -- dml ignores this migration"
|
|
||||||
|
|
||||||
|
|
||||||
class IgnoreMigration(Operation):
|
class IgnoreMigration(Operation):
|
||||||
|
|
||||||
reversible = True
|
reversible = True
|
||||||
# Must be true to be generated through the sqlmigrate command
|
reduces_to_sql = False
|
||||||
reduces_to_sql = True
|
|
||||||
|
|
||||||
def state_forwards(self, app_label, state):
|
def state_forwards(self, app_label, state):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def database_forwards(self, app_label, schema_editor, from_state, to_state):
|
def database_forwards(self, app_label, schema_editor, from_state, to_state):
|
||||||
schema_editor.execute(IGNORE_MIGRATION_SQL)
|
pass
|
||||||
|
|
||||||
def database_backwards(self, app_label, schema_editor, from_state, to_state):
|
def database_backwards(self, app_label, schema_editor, from_state, to_state):
|
||||||
schema_editor.execute(IGNORE_MIGRATION_SQL + " (reversed)")
|
pass
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
return "The Django migration linter will ignore this migration"
|
return "The Django migration linter will ignore this migration"
|
||||||
Reference in new issue
Block a user