diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-06-08 19:30:15 -0700 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-06-08 19:33:52 -0700 |
| commit | 08218252d8be4633ac0e94863da527d824648d63 (patch) | |
| tree | 7b2724bc7730960af1ba7b539192132ccae2f50c /docs/ref | |
| parent | bf019c977055ade45c5c260ed235bb5dcf7e2be7 (diff) | |
[1.7.x] Fixed #22487: Optional rollback emulation for migrated apps
Conflicts:
django/db/backends/creation.py
django/test/runner.py
docs/ref/settings.txt
docs/topics/testing/advanced.txt
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/migration-operations.txt | 13 | ||||
| -rw-r--r-- | docs/ref/settings.txt | 18 |
2 files changed, 29 insertions, 2 deletions
diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt index 40ef3849ac..95c9a65020 100644 --- a/docs/ref/migration-operations.txt +++ b/docs/ref/migration-operations.txt @@ -199,8 +199,9 @@ model:: # We get the model from the versioned app registry; # if we directly import it, it'll be the wrong version Country = apps.get_model("myapp", "Country") - Country.objects.create(name="USA", code="us") - Country.objects.create(name="France", code="fr") + db_alias = schema_editor.connection.alias + Country.objects.create(name="USA", code="us", using=db_alias) + Country.objects.create(name="France", code="fr", using=db_alias) class Migration(migrations.Migration): @@ -236,6 +237,14 @@ Oracle). This should be safe, but may cause a crash if you attempt to use the ``schema_editor`` provided on these backends; in this case, please set ``atomic=False``. +.. warning:: + + RunPython does not magically alter the connection of the models for you; + any model methods you call will go to the default database unless you + give them the current database alias (available from + ``schema_editor.connection.alias``, where ``schema_editor`` is the second + argument to your function). + SeparateDatabaseAndState ------------------------ diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index c695131565..7f41939735 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -2116,6 +2116,24 @@ The name of the class to use for starting the test suite. See Previously the default ``TEST_RUNNER`` was ``django.test.simple.DjangoTestSuiteRunner``. +.. setting:: TEST_NON_SERIALIZED_APPS + +TEST_NON_SERIALIZED_APPS +------------------------ + +Default: ``[]`` + +In order to restore the database state between tests for TransactionTestCases +and database backends without transactions, Django will :ref:`serialize the +contents of all apps with migrations <test-case-serialized-rollback>` when it +starts the test run so it can then reload from that copy before tests that +need it. + +This slows down the startup time of the test runner; if you have apps that +you know don't need this feature, you can add their full names in here (e.g. +``django.contrib.contenttypes``) to exclude them from this serialization +process. + .. setting:: THOUSAND_SEPARATOR THOUSAND_SEPARATOR |
