本文介绍了Laravel在"app/database/migrations"上运行迁移递归文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的迁移文件夹看起来像这样,因为我有几十个表,它使事情保持井井有条:

So my migrations folder looks like this since I have dozens of tables it keeps things organized and clean:

migrations/
  create_user_table.php
  relations/
  translations/

我正在尝试刷新所有迁移和种子,但似乎遇到了一些小麻烦,在此我不知道artisan命令以递归方式运行迁移(即在relationstranslations文件夹).

I'm trying to do a refresh all migrations and seed but it seems like I've run into a slight hiccup where I don't know the artisan command to run migrations recursively (i.e. run migrations in the relations and translations folders as well).

我尝试添加--path="app/database/migrations/*",但是它吐出了一个错误.有人知道解决方案吗?

I've tried adding --path="app/database/migrations/*" however it spat out an error. Does anyone know the solution to this?

推荐答案

目前唯一的方法是手动进行所有迁移.也就是说,您必须在每个子文件夹上运行迁移命令:

The only way to do it right now is to manually go through all the migrations. That is, you have to run the migration command on each of your subfolders:

php artisan migrate --path=/app/database/migrations/relations
php artisan migrate --path=/app/database/migrations/translations

但是,您可以做的就是轻松扩展artisan系统以编写自己的迁移命令,该命令将遍历migrations文件夹下的所有文件夹,为您创建并运行这些命令.

However, what you can do is easily extend the artisan system to write your own migrate command that will iterate through all folders under the migrations folder, create these commands for you and run them.

如果您不想通过artisan进行操作,也可以简单地编写一个shell脚本

You can also simply write a shell script if you don't want to get into doing this via artisan

对于Laravel> = 5.0,在子目录中迁移迁移文件的正确命令为:

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

这篇关于Laravel在"app/database/migrations"上运行迁移递归文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 03:33