Configuration

Configuration options for WPZylos Migrations.

Service Provider

The MigrationsServiceProvider registers migration components.

Container Bindings

BindingClassDescription
Migrator::classMigratorMigration runner
MigrationRepository::classMigrationRepositoryMigration state tracker

Migrations Path

Default: {plugin_dir}/database/migrations/

Custom path via constructor:

$migrator = new Migrator(
    $context,
    $db,
    $repository,
    '/custom/path/to/migrations'
);

Migration Tracking

Migration state is tracked in wp_options (or wp_sitemeta for network-activated plugins):

  • Ran migrations: Stored under key {prefix}migrations
  • Batch number: Stored under key {prefix}migrations_batch

Table Prefix

Tables created via Migration::create() are prefixed with the WordPress table prefix:

// In a migration's up() method
$this->create('orders', [
    'id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT',
    // ...
], ['PRIMARY KEY (id)']);
// Creates: wp_orders (uses $wpdb->prefix)