﻿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
11987	destroy_test_db can destroy the production database in some situations	eronen	nobody	"I have some tests which need to be run against the production database, so these test cases temporarily change settings.DATABASE_NAME. If those get interrupted (by e.g. Control-C) in the wrong place, settings.DATABASE_NAME might be left pointing to the production database.

Ticket #10868 describes another situation (involving threads) where destroy_test_db could end up destroying the wrong database.

There might be other reasons why this could happen. I would suggest rewriting this line in a bit safer way to avoid this ituation. Perhaps something like this:

{{{
OLD:
    test_database_name = settings.DATABASE_NAME
NEW:
    if settings.TEST_DATABASE_NAME:
        test_database_name = settings.TEST_DATABASE_NAME
    elif settings.DATABASE_NAME.startswith(TEST_DATABASE_PREFIX):
        test_database_name = settings.DATABASE_NAME
    else:
        test_database_name = TEST_DATABASE_PREFIX + settings.DATABASE_NAME
}}}
"		closed	Testing framework	1.1		invalid			Unreviewed	0	0	0	0	0	0
