Skip to content

Instantly share code, notes, and snippets.

@macbre
Last active July 12, 2016 08:53
Show Gist options
  • Save macbre/2c2ea3b814899e7974f9f64c5408c598 to your computer and use it in GitHub Desktop.
Save macbre/2c2ea3b814899e7974f9f64c5408c598 to your computer and use it in GitHub Desktop.
SMW migration

SMW migrator

  • Get the list of wikis with SMW enabled ($wgEnableSemanticMediaWikiExt = true) and that are not yet migrated to the new storage / DB schema (smwgDefaultStore not set in WikiFactory)
  • Run migrator.sh followed by switchStorage.sh for each of these wikis (provide city ID as an argument). The first one performs the schema migration (no changes are visible to the users at that moment), the latter one will switch WF variable to let SMW use new and more performant DB schema,
  • You're done :)

Cleanup

Once the migration is completed and the new storage is running fine the old schema can be removed by running the following:

/extensions/wikia/SemanticMediaWiki/maintenance$ SERVER_ID=627132 php SMW_setup.php --delete --nochecks --backend SMWSQLStore2
#!/bin/bash
SERVER_ID=$1
SMW_PATH="extensions/wikia/SemanticMediaWiki/maintenance/"
START_ID_FILE="/tmp/smw_startid_${SERVER_ID}"
date
echo "Running SMW migrator for wiki #${SERVER_ID}..."
sleep 1
# Setup the DB tables
run_maintenance --script="${SMW_PATH}/SMW_setup.php -b SMWSQLStore3" --id=${SERVER_ID} --verbose --ip=$WIKIA_DOCROOT
# Rebuild everything fully (will take ages, particularly for large wikias)
touch ${START_ID_FILE}
run_maintenance --script="${SMW_PATH}/SMW_refreshData.php -v -f -b SMWSQLStore3 --startidfile ${START_ID_FILE}" --id=${SERVER_ID} --verbose --ip=$WIKIA_DOCROOT
echo "Done"
date
#!/bin/bash
SERVER_ID=$1
SMW_PATH="extensions/wikia/SemanticMediaWiki/maintenance/"
START_ID_FILE="/tmp/smw_startid_${SERVER_ID}"
echo "Enabling new SMW storage for wiki #${SERVER_ID}..."
# switch to the new storage
run_maintenance --script="maintenance/wikia/setWikiFactoryVariable.php --verbose --varName=smwgDefaultStore --set=SMWSQLStore3 --wikiId=${SERVER_ID} --reason=\"SMW storage migrator\"" --id=${SERVER_ID} --verbose --ip=$WIKIA_DOCROOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment