File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 49
49
50
50
51
51
def create_databases ():
52
- """Creates the required test databases if they don't already exist ."""
53
- print ("--- Creating test databases ---" )
52
+ """Drops and recreates the required test databases to ensure they are empty ."""
53
+ print ("--- Resetting test databases ---" )
54
54
password = os .environ .get ("SINGLESTORE_PASSWORD" , "" )
55
55
databases_to_create = ["test_django_db" , "test_django_db_other" ]
56
56
@@ -60,11 +60,12 @@ def create_databases():
60
60
) as conn :
61
61
with conn .cursor () as cur :
62
62
for db_name in databases_to_create :
63
- print (f"Ensuring database '{ db_name } ' exists." )
64
- cur .execute (f"CREATE DATABASE IF NOT EXISTS `{ db_name } `;" )
63
+ print (f"Dropping and recreating database '{ db_name } ' to ensure it is empty." )
64
+ cur .execute (f"DROP DATABASE IF EXISTS `{ db_name } `;" )
65
+ cur .execute (f"CREATE DATABASE `{ db_name } `;" )
65
66
print ("--- Test databases are ready ---" )
66
67
except Exception as e :
67
- print (f"FATAL: Failed to create databases: { e } " )
68
+ print (f"FATAL: Failed to reset databases: { e } " )
68
69
sys .exit (1 )
69
70
70
71
You can’t perform that action at this time.
0 commit comments