madebit / wordpress-data-migration
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/madebit/wordpress-data-migration
This package is auto-updated.
Last update: 2025-11-12 19:06:53 UTC
README
How to use
create a folder in your working directory for the migrations.
mkdir migrations
Create a file called CURRENT_VERSION in this folder and insert the current version number
touch migrations/CURRENT_VERSION
echo '0' > migrations/CURRENT_VERSION
Include the DataMigration into your project.
add_action('init', function () {
new DataMigration(get_template_directory() . '/migrations/');
});
In the migrations folder, create a migration file. These files should be constructed with the version number and the classname. ${VERSION}-${ClassName}.php
touch migrations/1-DoThisAndThat.php
The file should look like this
<?php
namespace Madebit\WordpressDataMigration;
class DoThisAndThat extends \Madebit\WordpressDataMigration\AbstractMigration {
public function up()
{
// migrate data when migrating up
}
public function down()
{
// migrate data when migrating down
}
}
?>
To migrate, visit the Rest endpoint << YOUR INSTALL >>/wp-json/m8b/v1/migrate.
To test or execute a specific version add the ?version=<INT> parameter.