本文整理汇总了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)
示例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
)
示例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
)
示例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."""
示例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