Migrations
Migrations
“Load” is the easiest way to make the migration tables available to the Laravel application.
With load
your package migration tables are linked into your Laravel application and are accessed with the
“migrate” command, as is usual for Laravel apps.
Structure
- 2024_07_08_065131_nice_table.php
The advantage of integrating is that as soon as you change your package, the developer installs your package update, the changed or new migration files are immediately available in Laravel via
php artisan migrate:
Possible types to configure to load only migrations into laravel
Bootraiser Options
Possible instructions
with method
Raiser::forProvider($this)->Migrations();
Raiser::forProvider($this)->loadMigrations();
Raiser::forProvider($this)->publishMigrations();
with array
['Migrations']
['loadMigrations']
['publishMigrations']
via Method
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
Raiser::forProvider($this)->loadMigrations();
}
}
via config array
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
// or from your config
Raiser::forProvider($this)->loadMigrations();
}
}
Todo
- Migrations for package
enable publishing migrations
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
Raiser::forProvider($this)->publishMigrations();
}
}
vendor publish suggestion
php artisan vendor:publish
vendor publish result
vendor publish –tag
php artisan vendor:publish --tag=your-package-migrations
References
https://laravel.com/docs/11.x/packages#migrations
Todo
- Migrate + Migrate refresh + remove single Table with selectable command
php artisan migrate --path=app-demo/your-package/database/migrations/2024_08_04_151741_create_nice_models_table.php
Last updated on