6

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!

2
  • Well, atm, there is really no way. Only the actual file name is stored on the database, without its path and there is no path parameter for the rollback command. You could, of course, implement it the parameter, but that would be bad when you happen to have ran migrations from multiple paths. The best would probably find a way to store in the DB where that came from, fork the repo and propose the change.
    – rmobis
    Commented Aug 25, 2013 at 6:01
  • Nevermind, figured it out.
    – rmobis
    Commented Aug 26, 2013 at 4:17

2 Answers 2

5

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",
    ]
},
0
-2

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

2
  • would that drop the old tables, re-insert them and re-seed them again? Commented Aug 25, 2013 at 3:25
  • I've checked and yes, they do not remove the old data from the DB before you seed again.. Commented Aug 25, 2013 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.