CC-3175: Delete database tables on uninstall

-fixed
This commit is contained in:
Martin Konecny 2011-12-09 12:13:40 -05:00
parent 2d04d7eb83
commit 0077c8329f
2 changed files with 10 additions and 4 deletions

View File

@ -300,7 +300,7 @@ class AirtimeInstall
{
global $CC_DBC;
$defaultTimezone = date_default_timezone_get();
$defaultTimezone = exec("cat /etc/timezone");
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
$result = $CC_DBC->query($sql);

View File

@ -28,10 +28,16 @@ echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL;
// before this function, even if you called $CC_DBC->disconnect(), there will
// still be a connection to the database and you wont be able to delete it.
//------------------------------------------------------------------------
echo " * Dropping the database '".$CC_CONFIG['dsn']['database']."'...".PHP_EOL;
// check if DB exists
$command = "echo \"DROP DATABASE IF EXISTS ".$CC_CONFIG['dsn']['database']."\" | su postgres -c psql";
//close connection for any process id using airtime database since we are about to drop the database.
$sql = "SELECT pg_cancel_backend(procpid) FROM pg_stat_activity WHERE datname = 'airtime';";
$command = "echo \"$sql\" | su postgres -c psql";
@exec($command, $output);
echo " * Dropping the database '".$CC_CONFIG["dsn"]["database"]."'...".PHP_EOL;
//dropdb returns 1 if other sessions are using the database, otherwise returns 0
$command = "su postgres -c \"dropdb ".$CC_CONFIG["dsn"]["database"]."\"";
@exec($command, $output, $dbDeleteFailed);