Laravel 5 dynamically run migrations

前端 未结 3 1270
天命终不由人
天命终不由人 2021-01-05 02:11

so I have created my own blog package in a structure of Packages/Sitemanager/Blog I have a service provider that looks like the following:

names         


        
3条回答
  •  独厮守ぢ
    2021-01-05 02:30

    After publishing the package:

    php artisan vendor:publish --provider="Packages\Namespace\ServiceProvider"

    You can execute the migration using:

    php artisan migrate

    Laravel automatically keeps track of which migrations have been executed and runs new ones accordingly.

    If you want to execute the migration from outside of the CLI, for example in a route, you can do so using the Artisan facade:

    Artisan::call('migrate')

    You can pass optional parameters such as force and path as an array to the second argument in Artisan::call.

    Further reading:

    • https://laravel.com/docs/5.1/artisan
    • https://laravel.com/docs/5.2/migrations#running-migrations

提交回复
热议问题