简体   繁体   中英

Laravel 5.6: Migration from a specific folder

I am trying to use php artisan migrate --path="/database/migrations/ef to use only the migrations in that path. But I got "Nohting no migrate" and the migration files are in that direction.

I tried to adding this to boot method in AppServiceProvider, that is from this link Laravel running migrations on "app/database/migrations" folder recursively :

$mainPath = database_path('migrations');
$directories = glob($mainPath . '/*' , GLOB_ONLYDIR);
$paths = array_merge([$mainPath], $directories);

$this->loadMigrationsFrom($paths);

But it does not work either.

for Laravel >= 5.0, the correct commands to migrate migration files in sub directories would be:

php artisan migrate --path=/database/migrations/ef
php artisan migrate --path=/database/migrations/relations

I fixed it. (Not have "/" on first path)

I tried running the migrate creation command to find the error.

php artisan make: migration create_users_table --path=/path/to/your/migration/directory

Then composer dump. Finally, I think the correct command to run in the sub folder is:

php artisan migrate --path=database/migrations/subfolder

if you need to migrate spicific folder called User use
php artisan migrate --path=/database/migrations/User

if you need to migrate all folders in migrations folder use
php artisan migrate --path=/database/migrations/*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM