Skip to content

v13.1.0

Latest

Choose a tag to compare

@dimitriBouteille dimitriBouteille released this 14 Nov 17:54
6b80049

What's Changed

✨ Database migrations with WP-CLI

wp-orm now ships an optional migration system to manage your custom tables, based on Illuminate migrations and WP-CLI (#28). The migrations run through $wpdb, the WordPress prefix, charset and collation are applied
automatically.

composer require dbout/wp-orm:^13.1 illuminate/filesystem

Enable it once, e.g. in a must-use plugin:

// wp-content/mu-plugins/migrations.php
use Dbout\WpOrm\Migrations\Migrations;

Migrations::enable([
    'paths' => [__DIR__ . '/database/migrations'],
]);

Then manage your tables from the command line:

wp orm make:migration create_orders_table   # Create a migration file
wp orm migrate                              # Run the pending migrations
wp orm migrate:status                       # Show the status of each migration
wp orm migrate:rollback                     # Roll back the last batch
wp orm migrate:reset                        # Roll back all the migrations

📖 Documentation

Good to know

  • The feature is opt-in: nothing changes if you don't call Migrations::enable().
  • migrate:rollback and migrate:reset ask for a confirmation, use --yes in your deployment scripts.
  • Limitations: MySQL doesn't support transactional DDL (a migration failing halfway keeps its previous changes), no multisite support yet (#170), WP-CLI only, no migrate:fresh / migrate:refresh (they would
    drop the WordPress tables).

Full Changelog: v13.0.3...v13.1.0