I autoload migrations

This commit is contained in:
Fabian @ Blax Software 2026-05-11 14:38:30 +02:00
parent 019080f227
commit be6404ddf9
1 changed files with 13 additions and 2 deletions

View File

@ -27,13 +27,24 @@ class AddressesServiceProvider extends ServiceProvider
/** /**
* Bootstrap the application events. * Bootstrap the application events.
* *
* Publishes config and migration stubs, and registers model bindings * Publishes config and migration stubs, registers model bindings so
* so that the container always resolves the (possibly overridden) model. * that the container always resolves the (possibly overridden) model,
* and auto-loads any *additive* migrations the package ships in
* `database/migrations/` (plain .php files the create-tables
* baseline stays a `.stub` for vendor:publish only).
*/ */
public function boot(): void public function boot(): void
{ {
$this->offerPublishing(); $this->offerPublishing();
// Auto-load additive migrations (e.g. new columns / indexes) shipped
// with the package as plain `.php` files. The original `create_…`
// migration is a `.stub` and is therefore NOT picked up here —
// consumers must still `vendor:publish` it once to set the baseline
// (preserves backwards-compatibility with apps that already published
// a customised version, like UUID PKs).
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
$this->registerModelBindings(); $this->registerModelBindings();
} }