Traits
HasMigrations
v1.0.0Adds 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.
Works Well With
Helpers
public function getMigrationsPath(): stringReturns the module-local migrations directory path.
public function hasPendingMigrations(): boolChecks 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(),
]);
}
}