File: transactions-and-purging.rst

package info (click to toggle)
php-doctrine-data-fixtures 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 564 kB
  • sloc: php: 3,148; makefile: 20
file content (21 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Transactions and purging
========================

This package provides executors for ``doctrine/orm``, ``doctrine/mongodb-odm``
and ``doctrine/phpcr-odm``.

The executors purge the database, then load the fixtures. The ORM
implementation wraps these two steps in a database transaction, which
provides a nice additional property: atomicity.
Because of that transaction, the loading either succeeds or fails
cleanly, meaning nothing is actually changed in the database if the
loading fails. It delegates the purging to a separate class that can be
configured to either use a ``TRUNCATE`` or a ``DELETE`` statement to
empty tables.

Not all RDBMS have the capability to allow ``TRUNCATE`` statements
inside transactions though. Notably, MySQL will produce the infamous
"There is no active transaction" message when we attempt to close a
transaction that was already `implicitly closed`_.

.. _implicitly closed: https://www.doctrine-project.org/projects/doctrine-migrations/en/stable/explanation/implicit-commits