diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-11-12 19:49:09 -0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-11-20 20:42:38 +0100 |
| commit | f5ebdfce5c417f9844e86bccc2f12577064d4bad (patch) | |
| tree | 9e8228bae93ac2ebc0ec9de10baeff8c5793510b /django | |
| parent | 3e5b349535f011a51dc308898924786143000631 (diff) | |
Fixed #25388 -- Added an option to allow disabling of migrations during test database creation.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/base/creation.py | 21 | ||||
| -rw-r--r-- | django/db/utils.py | 11 |
2 files changed, 20 insertions, 12 deletions
diff --git a/django/db/backends/base/creation.py b/django/db/backends/base/creation.py index f36d60a5fe..dd3407bac3 100644 --- a/django/db/backends/base/creation.py +++ b/django/db/backends/base/creation.py @@ -61,16 +61,17 @@ class BaseDatabaseCreation: settings.DATABASES[self.connection.alias]["NAME"] = test_database_name self.connection.settings_dict["NAME"] = test_database_name - # We report migrate messages at one level lower than that requested. - # This ensures we don't get flooded with messages during testing - # (unless you really ask to be flooded). - call_command( - 'migrate', - verbosity=max(verbosity - 1, 0), - interactive=False, - database=self.connection.alias, - run_syncdb=True, - ) + if self.connection.settings_dict['TEST']['MIGRATE']: + # We report migrate messages at one level lower than that + # requested. This ensures we don't get flooded with messages during + # testing (unless you really ask to be flooded). + call_command( + 'migrate', + verbosity=max(verbosity - 1, 0), + interactive=False, + database=self.connection.alias, + run_syncdb=True, + ) # We then serialize the current state of the database into a string # and store it on the connection. This slightly horrific process is so people diff --git a/django/db/utils.py b/django/db/utils.py index 4bd119227f..28afa6cd07 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -194,8 +194,15 @@ class ConnectionHandler: raise ConnectionDoesNotExist("The connection %s doesn't exist" % alias) test_settings = conn.setdefault('TEST', {}) - for key in ['CHARSET', 'COLLATION', 'NAME', 'MIRROR']: - test_settings.setdefault(key, None) + default_test_settings = [ + ('CHARSET', None), + ('COLLATION', None), + ('MIGRATE', True), + ('MIRROR', None), + ('NAME', None), + ] + for key, value in default_test_settings: + test_settings.setdefault(key, value) def __getitem__(self, alias): if hasattr(self._connections, alias): |
