Laravel 4 migrate:rollback with --path on artisan CLI

独自空忆成欢 提交于 2020-01-03 10:57:28

问题


I'm having some roadblock on Laravel 4.

Since I can't make artisan:migrate generate migrations from inner folders of app/database/migrations (ex: app/database/migrations/app1)

I have this on my custom command app:migrate

/* default path */
$this->call('migrate'); 

/* custom path */
$this->call('migrate', array('--path' => 'app/database/migrations/app1')); 

but i also want an app:refresh command which will rollback all the migrations from the custom path then from the default path.. then re migrate and seed everything just like what migrate:refresh --seed does

how do i reverse this? calling:

$this->call('migrate:rollback', array('--path' => 'app/database/migrations/app1'));

will produce an error saying

[InvalidArgumentException]
The "--path" option does not exist.

can somebody help please.

thanks!


回答1:


All you have to do is make sure your migration classes can be autoloaded. The easiest way to do so is to add the path to the folder you're keeping them to composer.json's autoload.classmap:

...
"autoload": {
    "classmap": [
        ...
        "app/database/migrations/app1",
    ]
},



回答2:


You should re-run migrate with "--path" option manually for this case.



来源:https://stackoverflow.com/questions/18425311/laravel-4-migraterollback-with-path-on-artisan-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!