﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26822	New migrations not applied on clone databases (sqlite) when using --parallel and --keepdb option	Romain Garrigues	Youngkwang Yang	"I have noticed an issue when using `--parallel` and `--keepdb` option in test environment.

The first time I run my tests with both options, everything is fine.
If I run again my tests after having added a new migration, this migration is not applied to the clone databases, which makes the tests using these cloned databases fail.

After looking a bit on `test.runner.setup_databases` function, I noticed that the first database is created in `connection.creation.create_test_db` (with correct migrations applied to it), and then the cloned database creation happens in `connection.creation.clone_test_db`.

On sqlite, the function responsible of database cloning is `db.backend.sqlite3.creation._clone_test_db`, and in case of `keepdb` option, we don't touch the cloned databases:
{{{
if keepdb:
    return
}}}

But then, the migrations applied to the default database are not present in cloned ones.

I have noticed this behaviour on sqlite, I have not checked what happened on other databases.

If we remove this `keepdb` condition, that will work but slow down the test execution. A more interesting approach would probably be to apply migrations to all databases, not just the default one.

Any thoughts about that? Or maybe I have missed some details?


"	Bug	assigned	Testing framework	1.9	Normal			romain.garrigues.cs@… Sage Abdullah Youngkwang Yang	Accepted	1	0	0	1	0	0
