-database tables to drop are generated dynamically
This commit is contained in:
martin 2011-03-11 13:59:20 -05:00
parent a947306222
commit cbb534dfda
3 changed files with 21 additions and 139 deletions

View File

@ -41,6 +41,7 @@ installPostgresScriptingLanguage();
echo "* Creating Database Tables".PHP_EOL;
createAirtimeDatabaseTables();
doctrineMigrateTables(__DIR__);
echo "* Storage Directory Setup".PHP_EOL;
storageDirectorySetup($CC_CONFIG);

View File

@ -22,15 +22,6 @@ checkIfRoot();
echo "******************************* Uninstall Begin ********************************".PHP_EOL;
function airtime_uninstall_delete_files($p_path)
{
$command = "rm -rf $p_path";
exec($command);
}
//------------------------------------------------------------------------
// Delete the database
// Note: Do not put a call to airtime_db_connect()
@ -48,142 +39,26 @@ $command = "sudo -u postgres dropdb {$CC_CONFIG['dsn']['database']} 2> /dev/null
if ($dbDeleteFailed) {
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
airtime_db_connect(true);
if (!PEAR::isError($CC_DBC)) {
if (airtime_db_table_exists($CC_CONFIG['prefTable'])) {
echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['prefTable'];
airtime_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id");
if (!PEAR::isError($CC_DBC)) {
$sql = "select * from pg_tables where tableowner = 'airtime'";
$rows = airtime_get_query($sql);
foreach ($rows as $row){
$tablename = $row["tablename"];
echo " * Removing database table $tablename...";
if (airtime_db_table_exists($tablename)){
$sql = "DROP TABLE $tablename CASCADE";
airtime_install_query($sql, false);
$CC_DBC->dropSequence($tablename."_id");
}
echo "done.".PHP_EOL;
} else {
echo " * Skipping: database table $CC_CONFIG[prefTable]".PHP_EOL;
}
}
if (airtime_db_table_exists($CC_CONFIG['transTable'])) {
echo " * Removing database table ".$CC_CONFIG['transTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['transTable'];
airtime_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['transTable']."_id");
echo "done.".PHP_EOL;
} else {
echo " * Skipping: database table $CC_CONFIG[transTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['filesTable']." CASCADE";
airtime_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['filesTable']."_id");
} else {
echo " * Skipping: database table $CC_CONFIG[filesTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['playListTable'])) {
echo " * Removing database table ".$CC_CONFIG['playListTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playListTable']." CASCADE";
airtime_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['playListTable']."_id");
} else {
echo " * Skipping: database table $CC_CONFIG[playListTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['playListContentsTable'])) {
echo " * Removing database table ".$CC_CONFIG['playListContentsTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playListContentsTable'];
airtime_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['playListContentsTable']."_id");
} else {
echo " * Skipping: database table $CC_CONFIG[playListContentsTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['accessTable'])) {
echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['accessTable'];
airtime_install_query($sql);
} else {
echo " * Skipping: database table $CC_CONFIG[accessTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['permTable'])) {
echo " * Removing database table ".$CC_CONFIG['permTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['permTable'];
airtime_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['permTable']."_id");
echo "done.".PHP_EOL;
} else {
echo " * Skipping: database table $CC_CONFIG[permTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['sessTable'])) {
echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['sessTable'];
airtime_install_query($sql);
} else {
echo " * Skipping: database table $CC_CONFIG[sessTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['subjTable'])) {
echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
$CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id");
$sql = "DROP TABLE ".$CC_CONFIG['subjTable']." CASCADE";
airtime_install_query($sql, false);
echo "done.".PHP_EOL;
} else {
echo " * Skipping: database table $CC_CONFIG[subjTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['smembTable'])) {
echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['smembTable'];
airtime_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id");
echo "done.".PHP_EOL;
} else {
echo " * Skipping: database table $CC_CONFIG[smembTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['scheduleTable'])) {
echo " * Removing database table ".$CC_CONFIG['scheduleTable']."...";
airtime_install_query("DROP TABLE ".$CC_CONFIG['scheduleTable']);
} else {
echo " * Skipping: database table $CC_CONFIG[scheduleTable]".PHP_EOL;
}
if (airtime_db_table_exists($CC_CONFIG['backupTable'])) {
echo " * Removing database table ".$CC_CONFIG['backupTable']."...";
airtime_install_query("DROP TABLE ".$CC_CONFIG['backupTable']);
} else {
echo " * Skipping: database table $CC_CONFIG[backupTable]".PHP_EOL;
}
}
//Delete Database
//system("dropdb -h localhost -U airtime -W airtime");
//select * from pg_stat_activity where datname='airtime';
/*
$rows = airtime_get_query("select procpid from pg_stat_activity where datname='airtime'");
$rowsCount = count($rows);
for ($i=0; $i<$rowsCount; $i++){
$command = "kill -2 {$rows[$i]['procpid']}";
echo $command.PHP_EOL;
system($command);
}
echo "still here!";
system("dropdb -h localhost -U airtime -W airtime");
exit;
*/
//------------------------------------------------------------------------
// Delete the user
//------------------------------------------------------------------------

View File

@ -188,3 +188,9 @@ function doctrineMigrateTables($dir){
$command = "php $dir/../library/doctrine/migrations/doctrine-migrations.phar --configuration=$dir/DoctrineMigrations/migrations.xml --db-configuration=$dir/../library/doctrine/migrations/migrations-db.php --no-interaction migrations:migrate";
system($command);
}
function airtime_uninstall_delete_files($p_path)
{
$command = "rm -rf $p_path";
exec($command);
}