Skip to content
Snippets Groups Projects
Commit 93043844 authored by Glenn Proctor's avatar Glenn Proctor
Browse files

Check if database already exists before dropping it.

parent d95eddd4
No related branches found
No related tags found
No related merge requests found
......@@ -812,8 +812,17 @@ sub create {
if ($dbs{$dbname}) {
if ($create) {
$dbh->do( "DROP DATABASE $dbname" );
print "Removed existing database $dbname\n";
print "WARNING: about to drop database $dbname on $host:$port; yes to confirm, otherwise exit: ";
$| = 1; # flush stdout
my $p = <STDIN>;
chomp $p;
if ($p eq "yes") {
$dbh->do( "DROP DATABASE $dbname" );
print "Removed existing database $dbname\n";
} else {
print "$dbname NOT removed\n";
exit(1);
}
} else {
die("Database $dbname already exists. Use -create option to overwrite it.");
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment