CC-5089:
Uninstall with purge won't clear all tables and indexes -fixed
This commit is contained in:
parent
1895686c85
commit
582ddf7f40
|
@ -115,7 +115,7 @@ class AirtimeInstall
|
||||||
|
|
||||||
public static function DropSequence($p_sequenceName)
|
public static function DropSequence($p_sequenceName)
|
||||||
{
|
{
|
||||||
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName");
|
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,10 +51,10 @@ $command = "su postgres -c \"dropdb ".$CC_CONFIG["dsn"]["database"]."\"";
|
||||||
// We do this if dropping the database fails above.
|
// We do this if dropping the database fails above.
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
if ($dbDeleteFailed) {
|
if ($dbDeleteFailed) {
|
||||||
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
|
|
||||||
$connected = AirtimeInstall::DbConnect(false);
|
$connected = AirtimeInstall::DbConnect(false);
|
||||||
|
|
||||||
if ($connected) {
|
if ($connected) {
|
||||||
|
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "select * from pg_tables where tableowner = 'airtime'";
|
$sql = "select * from pg_tables where tableowner = 'airtime'";
|
||||||
try {
|
try {
|
||||||
|
@ -67,11 +67,27 @@ if ($dbDeleteFailed) {
|
||||||
$tablename = $row["tablename"];
|
$tablename = $row["tablename"];
|
||||||
echo " * Removing database table $tablename...";
|
echo " * Removing database table $tablename...";
|
||||||
|
|
||||||
if (AirtimeInstall::DbTableExists($tablename)) {
|
$sql = "DROP TABLE $tablename CASCADE";
|
||||||
$sql = "DROP TABLE $tablename CASCADE";
|
AirtimeInstall::InstallQuery($sql, false);
|
||||||
AirtimeInstall::InstallQuery($sql, false);
|
AirtimeInstall::DropSequence($tablename."_id");
|
||||||
AirtimeInstall::DropSequence($tablename."_id");
|
echo "done.".PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo " * Deleting database sequences...".PHP_EOL;
|
||||||
|
$sql = "SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';";
|
||||||
|
try {
|
||||||
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$rows = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$sequence = $row["relname"];
|
||||||
|
echo " * Removing database sequence $sequence...";
|
||||||
|
|
||||||
|
$sql = "DROP SEQUENCE $sequence CASCADE";
|
||||||
|
AirtimeInstall::InstallQuery($sql, false);
|
||||||
echo "done.".PHP_EOL;
|
echo "done.".PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue