当前位置: 首页>>代码示例>>Python>>正文


Python base.Operation方法代码示例

本文整理汇总了Python中django.db.migrations.operations.base.Operation方法的典型用法代码示例。如果您正苦于以下问题:Python base.Operation方法的具体用法?Python base.Operation怎么用?Python base.Operation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.db.migrations.operations.base的用法示例。


在下文中一共展示了base.Operation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _transform_view_field_operations

# 需要导入模块: from django.db.migrations.operations import base [as 别名]
# 或者: from django.db.migrations.operations.base import Operation [as 别名]
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) 
开发者ID:SectorLabs,项目名称:django-postgres-extra,代码行数:21,代码来源:patched_autodetector.py

示例2: database_forwards

# 需要导入模块: from django.db.migrations.operations import base [as 别名]
# 或者: from django.db.migrations.operations.base import Operation [as 别名]
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
            ) 
开发者ID:archesproject,项目名称:arches,代码行数:11,代码来源:extras.py

示例3: database_backwards

# 需要导入模块: from django.db.migrations.operations import base [as 别名]
# 或者: from django.db.migrations.operations.base import Operation [as 别名]
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
            ) 
开发者ID:archesproject,项目名称:arches,代码行数:11,代码来源:extras.py

示例4: state_forwards

# 需要导入模块: from django.db.migrations.operations import base [as 别名]
# 或者: from django.db.migrations.operations.base import Operation [as 别名]
def state_forwards(self, app_label, state):
        """Operation does not alter database state, only data.""" 
开发者ID:genialis,项目名称:resolwe,代码行数:4,代码来源:migration_ops.py

示例5: __init__

# 需要导入模块: from django.db.migrations.operations import base [as 别名]
# 或者: from django.db.migrations.operations.base import Operation [as 别名]
def __init__(self, state_operation: Operation) -> None:
        self.state_operation = state_operation 
开发者ID:SectorLabs,项目名称:django-postgres-extra,代码行数:4,代码来源:apply_state.py


注:本文中的django.db.migrations.operations.base.Operation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。