MCPcopy
hub / github.com/tortoise/tortoise-orm / _run_database_backward

Method _run_database_backward

tortoise/migrations/migration.py:163–185  ·  view source on GitHub ↗
(
        self,
        operation: Operation,
        old_state: State,
        new_state: State,
        schema_editor: BaseSchemaEditor,
        supports_transactions: bool,
    )

Source from the content-addressed store, hash-verified

161 await operation.database_forward(self.app_label, old_state, new_state, schema_editor)
162
163 async def _run_database_backward(
164 self,
165 operation: Operation,
166 old_state: State,
167 new_state: State,
168 schema_editor: BaseSchemaEditor,
169 supports_transactions: bool,
170 ) -> None:
171 # Only wrap individual operations if schema editor is not already atomic.
172 # Never wrap in a transaction when collecting SQL — no real DB needed.
173 atomic_operation = operation.atomic or (self.atomic and operation.atomic is not False)
174 if (
175 not schema_editor.collect_sql
176 and not schema_editor.atomic_migration
177 and atomic_operation
178 and supports_transactions
179 ):
180 async with in_transaction(schema_editor.client.connection_name):
181 await operation.database_backward(
182 self.app_label, old_state, new_state, schema_editor
183 )
184 else:
185 await operation.database_backward(self.app_label, old_state, new_state, schema_editor)

Callers 1

unapplyMethod · 0.95

Calls 2

in_transactionFunction · 0.90
database_backwardMethod · 0.45

Tested by

no test coverage detected