MigratorPlugin automatically discovers and registers migration directories from all enabled modules, making module migrations available to Laravel’s migration system.
Overview
This plugin scans each module for database migration directories and registers them with Laravel’s migrator. This allows you to run migrations across all modules using standard Artisan commands.Source Location
InterNACHI\Modular\Plugins\MigratorPlugin
Activation
The plugin uses theAfterResolving attribute to activate when the migrator is resolved:
This plugin automatically activates after the migrator is resolved from the service container, typically when running migration commands.
How It Works
1. Discovery Phase
Thediscover() method finds all migration directories:
2. Registration Phase
Thehandle() method registers each path with the migrator:
Expected Module Structure
For migrations to be discovered, they must be located in:Example Migration
Usage
Running Migrations
All module migrations are automatically included when running standard migration commands:Checking Migration Status
Migration Path Registration
The plugin registers the entire migration directory path, not individual migration files. Laravel’s migrator handles loading and running individual migrations.
Migration Naming
Follow Laravel’s standard migration naming convention:2024_01_15_100000_create_posts_table.php2024_01_15_100001_add_status_to_posts_table.php2024_01_16_080000_create_comments_table.php
Migrations run in chronological order based on their timestamp prefix, regardless of which module they belong to.
Testing
Module migrations work with Laravel’s testing database migrations:Dependencies
Illuminate\Database\Migrations\Migrator- Laravel’s migration systemInterNACHI\Modular\Support\FinderFactory- Directory discovery