IgnoreMigration operation fix (postgres compatibility fix)
This commit is contained in:
1 parent
a31c92754f
commit
0ce615ff19
1 file changed
+36
-36
@@ -1,36 +1,36 @@
|
|||||||
# Copyright 2019 3YOURMIND GmbH
|
# Copyright 2019 3YOURMIND GmbH
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from django.db.migrations.operations.base import Operation
|
from django.db.migrations.operations.base import Operation
|
||||||
|
|
||||||
IGNORE_MIGRATION_SQL = "-- dml ignores this migration"
|
IGNORE_MIGRATION_SQL = "select 1;"
|
||||||
|
|
||||||
|
|
||||||
class IgnoreMigration(Operation):
|
class IgnoreMigration(Operation):
|
||||||
|
|
||||||
reversible = True
|
reversible = True
|
||||||
# Must be true to be generated through the sqlmigrate command
|
# Must be true to be generated through the sqlmigrate command
|
||||||
reduces_to_sql = True
|
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)
|
schema_editor.execute(IGNORE_MIGRATION_SQL)
|
||||||
|
|
||||||
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)")
|
schema_editor.execute(IGNORE_MIGRATION_SQL)
|
||||||
|
|
||||||
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