Manual:MigrateComments.php

MediaWiki versions:
1.30 1.39
Category:MediaWiki code#MigrateComments.php

Details

migrateComments.php is a maintenance script that migrates comments from pre-1.30 columns to the 'comment' table.

$wgCommentTableSchemaMigrationStage needs to be set to MIGRATION_WRITE_NEW or MIGRATION_NEW for the script to do the migration.

While migrating comments in a table, the script assumes any rows with the ID field non-zero (e.g. ar_comment_id non-zero) have already been migrated. Also it assumes the new field name is the same as the old with '_id' appended. It blanks the old fields while migrating.

The script migrates the following columns:

Table Old column New column
revisionrev_commentrevcomment_comment_id
archivear_commentar_comment_id
ipblocksipb_reasonipb_reason_id
imageimg_descriptionimgcomment_description_id
oldimageoi_descriptionoi_description_id
filearchivefa_deleted_reasonfa_deleted_reason_id
filearchivefa_descriptionfa_description_id
recentchangesrc_commentrc_comment_id
logginglog_commentlog_comment_id
protected_titlespt_reasonpt_reason_id

The comments are finally stored in the column comment_text in the comment table.

To improve performance during the run-time of this script, for the tables revision and image, a temporary table named revision_comment_temp and image_comment_temp is being used during the migration. These two tables will be merged with the tables revision and images again in the future.

Usage

php migrateComments.php

See also

Category:Maintenance scripts
Category:Maintenance scripts Category:MediaWiki code