Traits

HasMigrations

v1.0.0

Adds migration path resolution and hasPendingMigrations checks for module-local migrations.

Use Trait

use Meteorack\Sdk\RuntimeWp\Traits\HasMigrations;

How To Use It

  • AbstractModule already satisfies the trait's base path requirements, so you mainly use it to inspect migration state from lifecycle hooks.
  • Use hasPendingMigrations() during activation or upgrade flows to decide when the module should prompt for or perform schema work.

Helpers

public function getMigrationsPath(): string

Returns the module-local migrations directory path.

public function hasPendingMigrations(): bool

Checks whether the module has unapplied migrations on disk.

Example

bootstrap.php
public function onActivate(): void
{
    if ($this->hasPendingMigrations()) {
        $this->getSdkContext()->logger()->warn('reports.pending_migrations', [
            'path' => $this->getMigrationsPath(),
        ]);
    }
}