12if ( getenv(
'MW_INSTALL_PATH' ) !==
false ) {
13 $IP = getenv(
'MW_INSTALL_PATH' );
16 $IP =
"$dir/../../..";
18require_once
"$IP/maintenance/Maintenance.php";
27 public function __construct() {
28 parent::__construct();
29 $this->addDescription(
'Migrates database schema to version 2.' );
30 $this->requireExtension(
'Translate' );
33 public function execute() {
34 $dbw = wfGetDB( DB_PRIMARY );
35 if ( !$dbw->tableExists(
'revtag', __METHOD__ ) ) {
36 $this->fatalError(
"Table revtag doesn't exist. Translate extension is not installed?" );
39 if ( !$dbw->tableExists(
'revtag_type', __METHOD__ ) ) {
40 $this->fatalError(
"Table revtag_type doesn't exist. Migration is already done." );
43 if ( $dbw->getType() !==
'mysql' ) {
44 $this->error(
'This migration script only supports mysql. Please help ' .
45 "us to write routine for {$dbw->getType()}.", 1 );
48 $table = $dbw->tableName(
'revtag' );
49 $dbw->query(
"ALTER TABLE $table MODIFY rt_type varbinary(60) not null", __METHOD__ );
53 [
'rtt_id',
'rtt_name' ],
58 foreach ( $res as $row ) {
61 [
'rt_type' => $row->rtt_name ],
62 [
'rt_type' => (
string)$row->rtt_id ],
67 $dbw->dropTable(
'revtag_type', __METHOD__ );
71$maintClass = TSchema2::class;
72require_once RUN_MAINTENANCE_IF_MAIN;
Script to convert Translate extension database schema to v2.