/** * Schema update to set up the needed database tables. * * @since 0.1 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate(DatabaseUpdater $updater) { global $wgDBtype; $updater->addExtensionUpdate(array('addTable', 'surveys', dirname(__FILE__) . '/sql/Survey.sql', true)); $updater->addExtensionUpdate(array('addIndex', 'surveys', 'surveys_survey_title', dirname(__FILE__) . '/sql/AddMissingIndexes.sql', true)); return true; }
function SemanticMailMerge_SchemaUpdates(DatabaseUpdater $updater) { $sqldir = __DIR__ . '/maintenance/'; $updater->addExtensionTable('smw_mailmerge', $sqldir . 'table.sql'); $updater->addExtensionIndex('smw_mailmerge', 'title', $sqldir . 'index.sql'); return true; }
/** * Schema update to set up the needed database tables. * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates * * @since 0.1 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate(DatabaseUpdater $updater) { $updater->addExtensionUpdate(array('addTable', 'contests', dirname(__FILE__) . '/Contest.sql', true)); $updater->addExtensionUpdate(array('addField', 'contests', 'contest_signup_email', dirname(__FILE__) . '/sql/AddContestEmailFields.sql', true)); $updater->addExtensionUpdate(array('applyPatch', dirname(__FILE__) . '/sql/UpdateContestantRatingField.sql', true)); return true; }
public static function onLoadExtensionSchemaUpdates(DatabaseUpdater $updater = null) { $dbDir = __DIR__ . '/db'; $updater->addExtensionUpdate(array('addtable', 'page_assessments', "{$dbDir}/addReviewsTable.sql", true)); $updater->addExtensionUpdate(array('addtable', 'page_assessments_log', "{$dbDir}/addLoggingTable.sql", true)); return true; }
/** * LoadExtensionSchemaUpdates hook handler * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates * @param DatabaseUpdater $updater */ public static function onLoadExtensionSchemaUpdates(DatabaseUpdater $updater) { if ($updater->getDB()->getType() != 'mysql') { throw new MWException('GeoData extension currently supports only MySQL'); } $updater->addExtensionTable('geo_tags', dirname(__FILE__) . '/GeoData.sql'); return true; }
public static function SetupSchema( DatabaseUpdater $du ) { $base = dirname( __FILE__ ) . '/schema'; $du->addExtensionTable( "ratings", "$base/ratings.sql"); $du->addExtensionTable( "project_stats", "$base/project_stats.sql" ); $du->addExtensionTable( "assessment_changelog", "$base/log.sql" ); $du->addExtensionTable( "selections", "$base/selections.sql" ); return true; }
/** * Schema update to set up the needed database tables. * * @since 0.1 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate($updater = null) { global $wgDBtype; if ($wgDBtype == 'mysql') { $updater->addExtensionUpdate(array('addTable', 'article_protection', dirname(__FILE__) . '/ArticleProtection.sql', true)); } return true; }
/** * Schema update to set up the needed database tables. * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates * * @since 0.1 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate(DatabaseUpdater $updater) { $updater->addExtensionTable('ep_orgs', dirname(__FILE__) . '/sql/EducationProgram.sql'); $updater->addExtensionUpdate(array('addTable', 'ep_oas_per_course', dirname(__FILE__) . '/sql/AddAmbassadorLinks.sql', true)); $updater->addExtensionUpdate(array('addField', 'ep_oas_per_course', 'opc_user_id', dirname(__FILE__) . '/sql/RenameAmbUserField.sql', true)); $updater->addExtensionUpdate(array('addField', 'ep_revisions', 'rev_object_identifier', dirname(__FILE__) . '/sql/AddRevIdentifier.sql', true)); return true; }
/** * Schema update to set up the needed database tables. * * @since 1.2 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate($updater = null) { $updater->addExtensionTable('uw_campaigns', dirname(__FILE__) . '/UploadWizard.sql'); $updater->addExtensionUpdate(array('addIndex', 'uw_campaigns', 'uw_campaigns_name', dirname(__FILE__) . '/sql/UW_IndexCampaignsName.sql', true)); $updater->addExtensionUpdate(array('addIndex', 'uw_campaign_conf', 'uw_cc_id_property', dirname(__FILE__) . '/sql/UW_IndexConfIdProp.sql', true)); $updater->addExtensionUpdate(array('addIndex', 'uw_campaign_conf', 'uw_cc_property', dirname(__FILE__) . '/sql/UW_IndexConfProp.sql', true)); return true; }
public static function describeDBSchema(DatabaseUpdater $updater = null) { $dir = __DIR__ . '/sql'; // For now, there's just a single SQL file for all DB types. $updater->addExtensionUpdate(array('addTable', 'approved_pages', "{$dir}/ApprovedRevs.sql", true)); $updater->addExtensionUpdate(array('modifyField', 'approved_pages', 'ap_user_group', "{$dir}/patch-ap_group-length-increase-255.sql", true)); $updater->addExtensionUpdate(array('addIndex', 'approved_pages', 'approved_pages_page_id', "{$dir}/patch-add-indices.sql", true)); return true; }
/** * @param DatabaseUpdater|null $updater * @return bool */ public static function ckSchema($updater = null) { if ($updater !== null) { $updater->addExtensionUpdate(array('addtable', 'online_status', dirname(__FILE__) . '/OnlineStatusBar.sql', true)); } else { global $wgExtNewTables; $wgExtNewTables[] = array('online_status', dirname(__FILE__) . '/OnlineStatusBar.sql'); } return true; }
/** * Schema update to set up the needed database tables. * * @since 1.2 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate($updater = null) { $dbfile = dirname(__FILE__) . '/UploadWizard.' . $updater->getDB()->getType() . '.sql'; if (!file_exists($dbfile)) { $dbfile = dirname(__FILE__) . '/UploadWizard.sql'; } $updater->addExtensionTable('uw_campaigns', $dbfile); $updater->addExtensionUpdate(array('addIndex', 'uw_campaigns', 'uw_campaigns_name', dirname(__FILE__) . '/sql/UW_IndexCampaignsName.sql', true)); $updater->addExtensionUpdate(array('addIndex', 'uw_campaigns', 'uw_campaigns_enabled', dirname(__FILE__) . '/sql/UW_IndexCampaignsEnabled.sql', true)); return true; }
/** * Schema update to set up the needed database tables. * * @since 0.1 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate($updater = null) { global $wgDBtype; if ($wgDBtype == 'mysql') { // Set up the current schema. if ($updater === null) { global $wgExtNewTables, $wgExtNewIndexes, $wgExtNewFields; $wgExtNewTables[] = array('votes', dirname(__FILE__) . '/Ratings.sql', true); $wgExtNewTables[] = array('votes_props', dirname(__FILE__) . '/Ratings.sql', true); } else { $updater->addExtensionUpdate(array('addTable', 'votes', dirname(__FILE__) . '/Ratings.sql', true)); $updater->addExtensionUpdate(array('addTable', 'votes_props', dirname(__FILE__) . '/Ratings.sql', true)); } } return true; }
public static function onLoadExtensionSchemaUpdates(DatabaseUpdater $updater) { $tables = array('wp_plan', 'wp_subscription', 'wp_old_usage', 'wp_wikiplace', 'wp_page', 'wp_old_subscription', 'wp_invitation', 'wp_invitation_category', 'wp_wpi_wpp', 'wp_member'); $mysql_dir = dirname(__FILE__) . '/schema/mysql'; foreach ($tables as $table) { $updater->addExtensionUpdate(array('addTable', $table, "{$mysql_dir}/{$table}.sql", true)); } $db = wfGetDB(DB_MASTER); if ($db->tableExists('wp_subscription') && !$db->fieldExists('wp_subscription', 'wps_wpi_id', __METHOD__)) { $db->sourceFile("{$mysql_dir}/add_wps_wpi_field.sql"); } if ($db->tableExists('wp_old_subscription') && !$db->fieldExists('wp_old_subscription', 'wpos_wpi_id', __METHOD__)) { $db->sourceFile("{$mysql_dir}/add_wpos_wpi_field.sql"); } return true; }
function execute() { global $wgVersion, $wgTitle, $wgLang; $wgLang = Language::factory('en'); $wgTitle = Title::newFromText("MediaWiki database updater"); $this->output("MediaWiki {$wgVersion} Updater\n\n"); if (!$this->hasOption('skip-compat-checks')) { $this->compatChecks(); } else { $this->output("Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n"); wfCountdown(5); } # Attempt to connect to the database as a privileged user # This will vomit up an error if there are permissions problems $db = wfGetDB(DB_MASTER); $this->output("Going to run database updates for " . wfWikiID() . "\n"); $this->output("Depending on the size of your database this may take a while!\n"); if (!$this->hasOption('quick')) { $this->output("Abort with control-c in the next five seconds (skip this countdown with --quick) ... "); wfCountDown(5); } $shared = $this->hasOption('doshared'); $updates = array('core', 'extensions'); if (!$this->hasOption('nopurge')) { $updates[] = 'purge'; } $updater = DatabaseUpdater::newForDb($db, $shared, $this); $updater->doUpdates($updates); foreach ($updater->getPostDatabaseUpdateMaintenance() as $maint) { $child = $this->runChild($maint); $child->execute(); } $this->output("\nDone.\n"); }
protected function applyPatch($path, $isFullPath = false, $msg = null) { $prevScroll = $this->db->scrollableCursor(false); $prevPrep = $this->db->prepareStatements(false); parent::applyPatch($path, $isFullPath, $msg); $this->db->scrollableCursor($prevScroll); $this->db->prepareStatements($prevPrep); }
/** * Schema update to set up the needed database tables. * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates * * @since 0.1 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate(DatabaseUpdater $updater) { $updater->addExtensionTable('ep_orgs', dirname(__FILE__) . '/sql/EducationProgram.sql'); $updater->addExtensionUpdate(array('addField', 'ep_orgs', 'org_courses', dirname(__FILE__) . '/sql/AddExtraFields.sql', true)); $updater->addExtensionUpdate(array('addField', 'ep_orgs', 'org_active', dirname(__FILE__) . '/sql/AddStatusFields.sql', true)); $updater->addExtensionUpdate(array('addField', 'ep_courses', 'course_instructors', dirname(__FILE__) . '/sql/AddMentorFields.sql', true)); $updater->addExtensionUpdate(array('addField', 'ep_terms', 'term_students', dirname(__FILE__) . '/sql/AddStudentsField.sql', true)); return true; }
public function execute() { $dbw = $this->getDB(DB_MASTER); $updater = DatabaseUpdater::newForDB($dbw, true, $this); foreach ($this->mArgs as $arg) { $files = [$arg, $updater->patchPath($dbw, $arg), $updater->patchPath($dbw, "patch-{$arg}.sql")]; foreach ($files as $file) { if (file_exists($file)) { $this->output("{$file} ...\n"); $dbw->sourceFile($file); continue 2; } } $this->error("Could not find {$arg}\n"); } $this->output("done.\n"); }
/** Wikia change -- moved getClientIPfromXFF() method to IP class */ public static function checkUserSchemaUpdates(DatabaseUpdater $updater) { $base = dirname(__FILE__); $updater->addExtensionUpdate(array('CheckUserHooks::checkUserCreateTables')); if ($updater->getDB()->getType() == 'mysql') { $updater->addExtensionUpdate(array('addIndex', 'cu_changes', 'cuc_ip_hex_time', "{$base}/archives/patch-cu_changes_indexes.sql", true)); $updater->addExtensionUpdate(array('addIndex', 'cu_changes', 'cuc_user_ip_time', "{$base}/archives/patch-cu_changes_indexes2.sql", true)); } return true; }
public static function onLoadExtensionSchemaUpdates(DatabaseUpdater $updater) { $base = dirname(__FILE__); $db = $updater->addExtensionTable('moderation', "{$base}/../sql/patch-moderation.sql"); $db = $updater->addExtensionTable('moderation_block', "{$base}/../sql/patch-moderation_block.sql"); }
public static function onLoadExtensionSchemaUpdates(DatabaseUpdater $updater) { $dir = __DIR__ . '/sql'; $updater->addExtensionTable('invitesignup', "{$dir}/invitesignup.sql"); }
/** * Schema update to set up the needed database tables. * * @since 0.1 * * @param DatabaseUpdater $updater * * @return true */ public static function onSchemaUpdate($updater = null) { global $wgDBtype, $egLiveTranslateIP; if ($wgDBtype == 'mysql') { // Set up the current schema. if ($updater === null) { global $wgExtNewTables, $wgExtNewIndexes, $wgExtNewFields; $wgExtNewTables[] = array('live_translate', $egLiveTranslateIP . '/LiveTranslate.sql', true); $wgExtNewTables[] = array('live_translate_memories', $egLiveTranslateIP . '/LiveTranslate.sql', true); $wgExtNewIndexes[] = array('live_translate', 'word_translation', $egLiveTranslateIP . '/sql/LT_IndexWordTranslation.sql', true); $wgExtNewFields[] = array('live_translate', 'memory_id', $egLiveTranslateIP . '/sql/LT_addTMField.sql'); $wgExtNewFields[] = array('live_translate_memories', 'memory_version_hash', $egLiveTranslateIP . '/sql/LT_addTMHashField.sql'); } else { $updater->addExtensionUpdate(array('addTable', 'live_translate', $egLiveTranslateIP . '/LiveTranslate.sql', true)); $updater->addExtensionUpdate(array('addTable', 'live_translate_memories', $egLiveTranslateIP . '/LiveTranslate.sql', true)); $updater->addExtensionUpdate(array('addIndex', 'live_translate', 'word_translation', $egLiveTranslateIP . '/sql/LT_IndexWordTranslation.sql', true)); $updater->addExtensionUpdate(array('addField', 'live_translate', 'memory_id', $egLiveTranslateIP . '/sql/LT_addTMField.sql', true)); $updater->addExtensionUpdate(array('addField', 'live_translate_memories', 'memory_version_hash', $egLiveTranslateIP . '/sql/LT_addTMHashField.sql', true)); } } return true; }
function execute() { global $wgVersion, $wgLang, $wgAllowSchemaUpdates; if (!$wgAllowSchemaUpdates && !($this->hasOption('force') || $this->hasOption('schema') || $this->hasOption('noschema'))) { $this->error("Do not run update.php on this wiki. If you're seeing this you should\n" . "probably ask for some help in performing your schema updates or use\n" . "the --noschema and --schema options to get an SQL file for someone\n" . "else to inspect and run.\n\n" . "If you know what you are doing, you can continue with --force\n", true); } $this->fileHandle = null; if (substr($this->getOption('schema'), 0, 2) === "--") { $this->error("The --schema option requires a file as an argument.\n", true); } elseif ($this->hasOption('schema')) { $file = $this->getOption('schema'); $this->fileHandle = fopen($file, "w"); if ($this->fileHandle === false) { $err = error_get_last(); $this->error("Problem opening the schema file for writing: {$file}\n\t{$err['message']}", true); } } $wgLang = Language::factory('en'); define('MW_UPDATER', true); $this->output("MediaWiki {$wgVersion} Updater\n\n"); wfWaitForSlaves(); if (!$this->hasOption('skip-compat-checks')) { $this->compatChecks(); } else { $this->output("Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n"); wfCountdown(5); } // Check external dependencies are up to date if (!$this->hasOption('skip-external-dependencies')) { $composerLockUpToDate = $this->runChild('CheckComposerLockUpToDate'); $composerLockUpToDate->execute(); } else { $this->output("Skipping checking whether external dependencies are up to date, proceed at your own risk\n"); } # Attempt to connect to the database as a privileged user # This will vomit up an error if there are permissions problems $db = $this->getDB(DB_MASTER); $this->output("Going to run database updates for " . wfWikiID() . "\n"); if ($db->getType() === 'sqlite') { $this->output("Using SQLite file: '{$db->getDbFilePath()}'\n"); } $this->output("Depending on the size of your database this may take a while!\n"); if (!$this->hasOption('quick')) { $this->output("Abort with control-c in the next five seconds " . "(skip this countdown with --quick) ... "); wfCountDown(5); } $time1 = microtime(true); $shared = $this->hasOption('doshared'); $updates = array('core', 'extensions'); if (!$this->hasOption('schema')) { if ($this->hasOption('noschema')) { $updates[] = 'noschema'; } $updates[] = 'stats'; } $updater = DatabaseUpdater::newForDb($db, $shared, $this); $updater->doUpdates($updates); foreach ($updater->getPostDatabaseUpdateMaintenance() as $maint) { $child = $this->runChild($maint); // LoggedUpdateMaintenance is checking the updatelog itself $isLoggedUpdate = $child instanceof LoggedUpdateMaintenance; if (!$isLoggedUpdate && $updater->updateRowExists($maint)) { continue; } $child->execute(); if (!$isLoggedUpdate) { $updater->insertUpdateRow($maint); } } $updater->setFileAccess(); if (!$this->hasOption('nopurge')) { $updater->purgeCache(); } $time2 = microtime(true); $timeDiff = $wgLang->formatTimePeriod($time2 - $time1); $this->output("\nDone in {$timeDiff}.\n"); }
/** * Perform database upgrades * * @return Boolean */ public function doUpgrade() { $this->setupSchemaVars(); $this->enableLB(); $ret = true; ob_start(array($this, 'outputHandler')); $up = DatabaseUpdater::newForDB($this->db); try { $up->doUpdates(); } catch (MWException $e) { echo "\nAn error occurred:\n"; echo $e->getText(); $ret = false; } $up->purgeCache(); ob_end_flush(); return $ret; }
private function prepareDB($version) { static $maint = null; if ($maint === null) { $maint = new FakeMaintenance(); $maint->loadParamsAndArgs(null, array('quiet' => 1)); } global $IP; $db = new DatabaseSqliteStandalone(':memory:'); $db->sourceFile("{$IP}/tests/phpunit/data/db/sqlite/tables-{$version}.sql"); $updater = DatabaseUpdater::newForDB($db, false, $maint); $updater->doUpdates(array('core')); return $db; }
/** * Implementation of the hook for loadExtensionSchemaUpdates * * Installs the requisite tables for this extension * * @param DatabaseUpdater $updater * * @return bool */ static function loadExtensionSchemaUpdates(DatabaseUpdater $updater) { $updater->addExtensionTable('accountaudit_login', __DIR__ . '/accountaudit.sql'); $updater->addExtensionField('accountaudit_login', 'aa_method', __DIR__ . '/patches/add_method.sql'); return true; }
/** * Overload: after this action field info table has to be rebuilt * * @param $what array */ public function doUpdates($what = array('core', 'extensions', 'purge', 'stats')) { parent::doUpdates($what); $this->db->query('BEGIN fill_wiki_info; END;'); }
/** * maybeUpgrade * * look for existence of some columns in database. If they are not exist * run database upgrade on first request. Not very efficient for regular * usage but good for transition time */ private function maybeUpgrade() { wfProfileIn(__METHOD__ . "-upgradedb"); $dbr = $this->getDB(); /** * look for rev_sha1 in revision table */ if (!$dbr->fieldExists("revision", "rev_sha1", __METHOD__)) { $ret = true; ob_start(array($this, 'outputHandler')); try { $up = DatabaseUpdater::newForDB($this->db); $up->doUpdates(); } catch (MWException $e) { $this->debug("An error occured: " . $e->getText()); $ret = false; } ob_end_flush(); wfProfileOut(__METHOD__ . "-upgradedb"); return $ret; } wfProfileOut(__METHOD__ . "-upgradedb"); }
public static function addDatabases(DatabaseUpdater $updater) { $updater->addExtensionUpdate(array('addTable', SqlSentences::$ratingRecordTable, __DIR__ . '/sql/create-rating-history-table.sql', true)); return true; }
/** * @param DatabaseUpdater $updater * @return bool */ public static function addSchemaUpdates(DatabaseUpdater $updater) { $base = dirname(__FILE__); if ($updater->getDB()->getType() == 'mysql') { $base = "{$base}/mysql"; $updater->addExtensionTable('account_requests', "{$base}/ConfirmAccount.sql", true); $updater->addExtensionField('account_requests', 'acr_filename', "{$base}/patch-acr_filename.sql"); $updater->addExtensionTable('addTable', 'account_credentials', "{$base}/patch-account_credentials.sql", true); $updater->addExtensionField('account_requests', 'acr_areas', "{$base}/patch-acr_areas.sql", true); $updater->addExtensionIndex('account_requests', 'acr_email', "{$base}/patch-email-index.sql", true); } elseif ($updater->getDB()->getType() == 'postgres') { $base = "{$base}/postgres"; $updater->addExtensionUpdate(array('addTable', 'account_requests', "{$base}/ConfirmAccount.pg.sql", true)); $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_held', "TIMESTAMPTZ")); $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_filename', "TEXT")); $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_storage_key', "TEXT")); $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_comment', "TEXT NOT NULL DEFAULT ''")); $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_type', "INTEGER NOT NULL DEFAULT 0")); $updater->addExtensionUpdate(array('addTable', 'account_credentials', "{$base}/patch-account_credentials.sql", true)); $updater->addExtensionUpdate(array('addPgField', 'account_requests', 'acr_areas', "TEXT")); $updater->addExtensionUpdate(array('addPgField', 'account_credentials', 'acd_areas', "TEXT")); $updater->addExtensionUpdate(array('addIndex', 'account_requests', 'acr_email', "{$base}/patch-email-index.sql", true)); } return true; }