IgnoreMigration operation fix (postgres compatibility fix)

This commit is contained in:
Serj Zavadsky committed 2019-01-29 16:52:08 +01:00
1 parent a31c92754f
commit 0ce615ff19
1 file changed
+36 -36
+36 -36
View File
@@ -1,36 +1,36 @@
# Copyright 2019 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.db.migrations.operations.base import Operation
IGNORE_MIGRATION_SQL = "-- dml ignores this migration"
class IgnoreMigration(Operation):
reversible = True
# Must be true to be generated through the sqlmigrate command
reduces_to_sql = True
def state_forwards(self, app_label, state):
pass
def database_forwards(self, app_label, schema_editor, from_state, to_state):
schema_editor.execute(IGNORE_MIGRATION_SQL)
def database_backwards(self, app_label, schema_editor, from_state, to_state):
schema_editor.execute(IGNORE_MIGRATION_SQL + "(reversed)")
def describe(self):
return "The Django migration linter will ignore this migration"
# Copyright 2019 3YOURMIND GmbH
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.db.migrations.operations.base import Operation
IGNORE_MIGRATION_SQL = "select 1;"
class IgnoreMigration(Operation):
reversible = True
# Must be true to be generated through the sqlmigrate command
reduces_to_sql = True
def state_forwards(self, app_label, state):
pass
def database_forwards(self, app_label, schema_editor, from_state, to_state):
schema_editor.execute(IGNORE_MIGRATION_SQL)
def database_backwards(self, app_label, schema_editor, from_state, to_state):
schema_editor.execute(IGNORE_MIGRATION_SQL)
def describe(self):
return "The Django migration linter will ignore this migration"