public static function InstallPostgresScriptingLanguage()
 {
     $con = Propel::getConnection();
     // Install postgres scripting language
     $sql = 'SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'';
     $langIsInstalled = $con->query($sql)->fetchColumn(0);
     if ($langIsInstalled == '0') {
         echo " * Installing Postgres scripting language" . PHP_EOL;
         $sql = "CREATE LANGUAGE 'plpgsql'";
         AirtimeInstall::InstallQuery($sql, false);
     } else {
         echo "  * Postgres scripting language already installed" . PHP_EOL;
     }
 }
            AirtimeInstall::InstallQuery($sql, false);
            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;
        }
    }
}
//------------------------------------------------------------------------
// Delete the user
//------------------------------------------------------------------------
echo " * Deleting database user '{$CC_CONFIG['dsn']['username']}'..." . PHP_EOL;
$command = "echo \"DROP USER IF EXISTS {$CC_CONFIG['dsn']['username']}\" | su postgres -c psql >/dev/null 2>&1";
@exec($command, $output, $results);
if ($results == 0) {
    echo "   * User '{$CC_CONFIG['dsn']['username']}' deleted." . PHP_EOL;
} else {
    echo "   * Nothing to delete." . PHP_EOL;
}
Example #3
0
 public static function InstallPostgresScriptingLanguage()
 {
     global $CC_DBC;
     // Install postgres scripting language
     $langIsInstalled = $CC_DBC->GetOne('SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'');
     if ($langIsInstalled == '0') {
         echo "* Installing Postgres scripting language" . PHP_EOL;
         $sql = "CREATE LANGUAGE 'plpgsql'";
         AirtimeInstall::InstallQuery($sql, false);
     } else {
         echo "* Postgres scripting language already installed" . PHP_EOL;
     }
 }