function run_update_scripts() { global $path_prefix, $base_url; if (!defined("PEEPAGG_UPDATING")) { define("PEEPAGG_UPDATING", 1); } upd_write("Running database upgrade script ..."); $upd = new db_update_page(); $upd->main(); upd_write("Installing default module settings ..."); if (!(include "{$path_prefix}/db/script_module_settings_data.php")) { throw new PAException(GENERAL_SOME_ERROR, "Unable to install default module settings"); } }
function __construct() { // set to false to only update a single network (see: $this->update_single_network($network_name)) $this->full_update = TRUE; // set to true to run update without any output $this->quiet = db_update_page::check_quiet(); $this->running_on_cli = !isset($_SERVER['REQUEST_METHOD']); }
function run_update_scripts($silent = false) { if (!defined("PEEPAGG_UPDATING")) { define("PEEPAGG_UPDATING", 1); } if (!$silent) { upd_write("Running database upgrade script ..."); } $upd = new db_update_page(); $upd->main(); /* No longer used upd_write("Installing default module settings ..."); if (!include("api/DB/script_module_settings_data.php")) throw new PAException(GENERAL_SOME_ERROR, "Unable to install default module settings"); */ }
public function do_updates() { // ALL DATABASE UPDATES GO IN HERE! // FOR EACH SQL STATEMENT YOU WANT TO EXECUTE, GIVE IT A 'KEY', THEN CALL: // $this->qup("key", "sql statement"); // eg. $this->qup("new foobar table", "create table foobar (id int not null, primary key(id))"); // YOU SHOULD NORMALLY PUT YOUR UPDATES AT THE *END* OF THIS FUNCTION. /** NOTE: KEY must be unique for each update query */ /** EXAMPLE ADD NEW TABLE */ /* $this->qup("new mc_feeds table", "CREATE TABLE mc_feeds ( user_id int not null, id int not null auto_increment, primary key(user_id,id), feed_url text not null, feed_name varchar(255) )"); */ /** EXAMPLE ALTER TABLE */ // $this->qup("add feed_description to mc_feeds", "ALTER TABLE mc_feeds ADD COLUMN feed_description TEXT"); /** EXAMPLE INSERT INTO TABLE */ // $this->qup("insert default data 1 for relation classifications", "INSERT INTO `relation_classifications` (`relation_type`, `relation_type_id`) VALUES ('acquaintance', '1');"); /** EXAMPLE UPDATE TABLE */ // $this->qup("changed id field in review-type movie", "UPDATE review_type SET review_id = 1 WHERE review_name = 'Movie'"); // finally, run the 'safe' updates in net_extra.php. /* require_once('api/Contribution/Contribution.php'); $this->qup( '2010-09-25, by: Jonathan Knapp - adding Conversation content_type', 'INSERT INTO {content_types} (type_id, name, description) VALUES ('.Conversation::TYPE_ID.', "'.Conversation::TYPE_NAME.'", "'.Conversation::TYPE_DESCRIPTION.'")' ); */ /** @todo: I don't like that I have to call the parent::do_updates() call after adding the project db updates, but I need to have the end of the parent's do_update() method actually make the calls. */ parent::do_updates(); }
/** * Do network setup * @access public * @param */ public function do_network_setup() { // global var $path_prefix has been removed - please, use PA::$path static variable Logger::log("[Enter: function Network::do_network_setup]\n"); //1. create folder with network address $network_dir = PA::$project_dir . '/networks/' . $this->address; $network_name = $this->address; $database_name = CURRENT_DB; //TODO find db name if (!mkdir($network_dir, 0777)) { Logger::log("Thowing Exception NETWORK_MKDIR_FAILED"); throw new PAException(NETWORK_MKDIR_FAILED, "Failed to create network directory ({$network_dir})"); } //2. (deleted) //3. make PeepAgg.mysql for network and copy it here if (file_exists(PA::$project_dir . '/api/DB/PeepAgg_tmpl.mysql')) { $source = PA::$project_dir . '/api/DB/PeepAgg_tmpl.mysql'; } else { if (file_exists(PA::$core_dir . '/api/DB/PeepAgg_tmpl.mysql')) { $source = PA::$core_dir . '/api/DB/PeepAgg_tmpl.mysql'; } } $destination = $network_dir . '/PeepAgg.mysql'; if ($handle = @fopen($source, "r")) { $content = fread($handle, filesize($source)); $content = str_replace('/%network_name%/', $network_name, $content); if ($handle_w = fopen($destination, "w")) { if (!fwrite($handle_w, $content)) { Logger::log("Thowing Exception NETWORK_FILE_WRITE"); throw new PAException(NETWORK_FILE_WRITE, "Network file could not be written."); } fclose($handle_w); } fclose($handle); } //4. open PeepAgg.mysql and create tables for network # if we have come this far then all went well and we can create new tables $file_content = file($network_dir . '/PeepAgg.mysql'); $query = ""; if (!$file_content) { Logger::log("Thowing Exception NETWORK_MYSQL_FILE"); throw new PAException(NETWORK_MYSQL_FILE, "Database cant be configured" . PA::$project_dir); } foreach ($file_content as $sql_line) { $tsl = trim($sql_line); if ($sql_line != "" && substr($tsl, 0, 2) != "--" && substr($tsl, 0, 1) != "#") { $query .= $sql_line; if (preg_match("/;\\s*\$/", $sql_line)) { $query = trim($query); $res = Dal::query($query); $query = ""; } } } //5. Run database update script to bring everything up to date define("PEEPAGG_UPDATING", 1); require_once "web/extra/db_update.php"; try { $upd = new db_update_page(); $upd->update_single_network($this->address); } catch (Exception $e) { echo $e->getMessage(); die; } Logger::log("[Exit: function Network::do_network_setup]\n"); return; }
* [filename] is a part of PeopleAggregator. * [description including history] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ // if a paproject db_update.php file exists, include it instead if (file_exists(PA::$project_dir . '/web/extra/project_db_update_page.class.php')) { require_once PA::$project_dir . '/web/extra/project_db_update_page.class.php'; } else { require_once PA::$core_dir . "/web/extra/db_update_page.class.php"; } $running_from_script = false; $is_quiet = db_update_page::check_quiet(); if (false !== strpos($_SERVER['SCRIPT_NAME'], 'run_scripts.php')) { $running_from_script = true; // echo "SCRIPT:" . $_SERVER['SCRIPT_NAME'] . "<br>"; } if (!$is_quiet && $running_from_script) { ?> <html> <head> <link rel="stylesheet" type="text/css" href="/extra/update.css" media="screen" /> </head> <body> <table> <?php } if (!$is_quiet) {