问题
I've created Payment package for my laravel project
I want to make migration files inside migrations folder of my package. How can create it using artisan command? I want something like
php artisan make:migration packages/Payment/src/Database/add_orderId_to_cart_payment_table
回答1:
Use this command on root folder
php artisan make:migration create_products_table --create=products
//create only Migration file
php artisan make:model Product -m
//Create Migration, Model file
php artisan make:model Product -mcr
//For Create Migration,Model,Controller file
If you want to do as manual then you may set --path as per your folder.
php artisan make:migration filename --path=/app/database/migrations/relations
php artisan make:migration filename --path=/app/database/migrations/translations
回答2:
For specific directories:
php artisan make:migration create_users_table --path=/packages/Payment/src/Database
The new migration will be placed in your packages/Payment/src/Database
directory.
For Running Migrations: php artisan migrate --path=/packages/Payment/src/Database
Generating a migration using the inbuilt framework feature:
php artisan make:migration create_users_table
The new migration will be placed in your database/migrations
directory.
For Running Migrations: php artisan migrate
回答3:
you need to publish them from your package to your migrations folder like this in your package service provider boot method:
$this->publishes([
__DIR__.'/Database/migrations/' => database_path('migrations'),
], 'migrations');
run this command php artisan vendor:publish --tag=migrations
and after that you can run php artisan migrate
来源:https://stackoverflow.com/questions/57230525/laravel-create-migration-file-in-specific-folder