madebit / wordpress-data-migration
There is no license information available for the latest version (0.0.4) of this package.
0.0.4
2021-02-12 07:46 UTC
This package is auto-updated.
Last update: 2024-11-12 17:14:44 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.