Well, I do have a package take I only use alongside with my system. I do have migrations for that package (it was build on Laravel 4.2, and I'm upgrading it).
That being said: On my package (former workbench) on Laravel 5.1, where do I put and how do I run my migrations?
Does any of you guys know how to deal with this?
UPDATE:
This is not the case of a simple migration. Back on laravel 4.*, we were able to maintain migrations for each package (if it was so desirable), and I do have some migrations been held by my own package, in it's own database, with it's own table. So... I need it to be a PACKAGE's migrations and not a ROOT INSTALATION's migration.
You can put it in packages/.../src/migrations
.
To run it:
"autoload": {
"classmap": [
"database",
"packages/.../src/migrations"
],
Or just call :
php artisan migrate --package="{vendor}/{name}"
php artisan migrate --path=/packages/.../migrations
For more info : check this blog from websanova.com
https://laravel.com/docs/5.6/packages#migrations says:
If your package contains database migrations, you may use the loadMigrationsFrom method to inform Laravel how to load them. The loadMigrationsFrom method accepts the path to your package's migrations as its only argument:
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
$this->loadMigrationsFrom(__DIR__.'/path/to/migrations');
}
Once your package's migrations have been registered, they will automatically be run when the php artisan migrate command is executed. You do not need to export them to the application's main database/migrations directory.
The forward-slash is important. In my case, I used: $this->loadMigrationsFrom(__DIR__ . "/migrations");
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With