Python django.db.migrations.operations.base.Operation() Examples

The following are 8 code examples of django.db.migrations.operations.base.Operation(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.db.migrations.operations.base , or try the search function .
Example #1
Source File: patched_autodetector.py    From django-postgres-extra with MIT License 6 votes vote down vote up
def _transform_view_field_operations(self, operation: Operation):
        """Transforms operations on fields on a (materialized) view into state
        only operations.

        One cannot add/remove/delete fields on a (materialized) view,
        however, we do want Django's migration system to keep track of
        these kind of changes to the model. The :see:ApplyState
        operation just tells Django the operation was applied without
        actually applying it.
        """

        model = self.autodetector.new_apps.get_model(
            self.app_label, operation.model_name
        )

        if issubclass(model, PostgresViewModel):
            return self.add(operations.ApplyState(state_operation=operation))

        return self.add(operation) 
Example #2
Source File: extras.py    From arches with GNU Affero General Public License v3.0 5 votes vote down vote up
def database_forwards(self, app_label, schema_editor, from_state, to_state):
        try:
            schema_editor.execute('CREATE EXTENSION IF NOT EXISTS "%s"' % self.name)
        except Error as e:
            self.logger.warning(
                'Operation to create extension "%s" failed. Must be executed by Postgres superuser \
account before running Arches.'
                % self.name
            ) 
Example #3
Source File: extras.py    From arches with GNU Affero General Public License v3.0 5 votes vote down vote up
def database_backwards(self, app_label, schema_editor, from_state, to_state):
        try:
            schema_editor.execute('DROP EXTENSION IF EXISTS "%s"' % self.name)
        except Error as e:
            self.logger.warning(
                'Operation to drop extension "%s" failed. Must be executed by Postgres superuser \
account.'
                % self.name
            ) 
Example #4
Source File: migration_ops.py    From resolwe with Apache License 2.0 5 votes vote down vote up
def state_forwards(self, app_label, state):
        """Operation does not alter database state, only data.""" 
Example #5
Source File: migration_ops.py    From resolwe with Apache License 2.0 5 votes vote down vote up
def state_forwards(self, app_label, state):
        """Operation does not alter database state, only data.""" 
Example #6
Source File: migration_ops.py    From resolwe with Apache License 2.0 5 votes vote down vote up
def state_forwards(self, app_label, state):
        """Operation does not alter database state, only data.""" 
Example #7
Source File: migration_ops.py    From resolwe with Apache License 2.0 5 votes vote down vote up
def state_forwards(self, app_label, state):
        """Operation does not alter database state, only data.""" 
Example #8
Source File: apply_state.py    From django-postgres-extra with MIT License 5 votes vote down vote up
def __init__(self, state_operation: Operation) -> None:
        self.state_operation = state_operation