/** * Update database schema */ public static function update_database_schema($po_opts = null) { require_once __CA_LIB_DIR__ . "/ca/ConfigurationCheck.php"; $o_config_check = new ConfigurationCheck(); if (($vn_current_revision = ConfigurationCheck::getSchemaVersion()) < __CollectiveAccess_Schema_Rev__) { CLIUtils::addMessage(_t("Are you sure you want to update your CollectiveAccess database from revision %1 to %2?\nNOTE: you should backup your database before applying updates!\n\nType 'y' to proceed or 'N' to cancel, then hit return ", $vn_current_revision, __CollectiveAccess_Schema_Rev__)); flush(); ob_flush(); $confirmation = trim(fgets(STDIN)); if ($confirmation !== 'y') { // The user did not say 'y'. return false; } $va_messages = ConfigurationCheck::performDatabaseSchemaUpdate(); print CLIProgressBar::start(sizeof($va_messages), _t('Updating database')); foreach ($va_messages as $vs_message) { print CLIProgressBar::next(1, $vs_message); } print CLIProgressBar::finish(); } else { print CLIProgressBar::finish(); CLIUtils::addMessage(_t("Database already at revision %1. No update is required.", __CollectiveAccess_Schema_Rev__)); } return true; }
#!/usr/local/bin/php <?php if (!file_exists('./setup.php')) { die("ERROR: Can't load setup.php. Please create the file in the same directory as this script or create a symbolic link to the one in your web root.\n"); } $_SERVER['HTTP_HOST'] = $argv[1]; require_once "./setup.php"; require_once __CA_LIB_DIR__ . "/ca/ConfigurationCheck.php"; if ($argv[1]) { $o_config_check = new ConfigurationCheck(); if (($vn_current_revision = ConfigurationCheck::getSchemaVersion()) < __CollectiveAccess_Schema_Rev__) { //print "Are you sure you want to update your CollectiveAccess database from revision {$vn_current_revision} to ".__CollectiveAccess_Schema_Rev__."?\nNOTE: you should backup your database before applying updates!\n\nType 'y' to proceed or 'N' to cancel, then hit return "; //flush(); //ob_flush(); //$confirmation = trim( fgets( STDIN ) ); //if ( $confirmation !== 'y' ) { // The user did not say 'y'. // exit (0); //} $va_messages = ConfigurationCheck::performDatabaseSchemaUpdate(); print "\n\n"; print "[" . $argv[1] . "] Applying database migrations...\n"; foreach ($va_messages as $vs_message) { print "\t{$vs_message}\n"; } } else { print "[" . $argv[1] . "] Database already at revision " . __CollectiveAccess_Schema_Rev__ . ". No update is required.\n"; } } else { foreach ($va_systems as $vs_host => $va_system_info) { passthru('php ./updateDatabaseSchema.php ' . $vs_host, $vn_ret_);