Deleting all Wikibase Items and/or Properties

Deleting all Wikibase Items and/or Properties

Do you wish to start over in your Wikibase after some experimentation? You could reinstall the entire wiki, but perhaps you wish to retain some content, users, uploads or similar. This post shows you how to get rid of all your Items and/or Properties without needing to bother with a full reinstall.

Step 1: Enable Nuke

We will delete Items and Properties via the Nuke extension. Since this extension comes bundled with MediaWiki, all you need to do is enable it. This takes a single line in LocalSettings.php:

wfLoadExtension( 'Nuke' );

Step 2: Delete pages

Go to Special:Nuke and delete the pages in the Items and Properties namespaces. Begin by selecting either the Item or Property namespace. Leave the first field blank, and enter % in the “SQL LIKE pattern” field. Then submit the form.

Optional Step 3: Reset Wikibase ID counters

Once you deleted the pages using step 2, you’ll be ready to create new Items and/or Properties. If you had 500 Items in your wiki already, creating a new one will now result in it getting ID Q501, rather than Q1. If you wish to also reset these numbers, so you can start with Q1 again, you also need to run the following commands before creating new Items:

echo 'SELECT * FROM /*_*/wb_id_counters;' | php maintenance/sql.php
echo 'UPDATE /*_*/wb_id_counters SET id_value = 0 WHERE id_type = "wikibase-item";' | php maintenance/sql.php
echo 'UPDATE /*_*/wb_id_counters SET id_value = 0 WHERE id_type = "wikibase-property";' | php maintenance/sql.php
echo 'SELECT * FROM /*_*/wb_id_counters;' | php maintenance/sql.php

Remove the wikibase-item or wikibase-property line if you are only deleting entities of the other type.

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *