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:30:15 -0700 |
| commit | 8c12d51ea27479555e226894c50c83043211d71d (patch) | |
| tree | db1e1e462f3a9eaf56733fce6c87aabb1b498705 /docs/ref | |
| parent | 8721adcbfbc0bba7fe8341605a4ab4dffd9774d6 (diff) | |
Fixed #22487: Optional rollback emulation for migrated apps
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 683d0f4b0f..64f2d6e213 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -2078,6 +2078,24 @@ Default: ``'django.test.runner.DiscoverRunner'`` The name of the class to use for starting the test suite. See :ref:`other-testing-frameworks`. +.. 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 |
