Laravel 4 migrate rollback problems
Solution 1:
Maybe you've already solved this issue. But I'm noticing that for some reason a rollback often requires you to run composer dumpautoload
first. Even if your migration works.
Solution 2:
Having just wrestled with this problem for several days, I think I can now provide the definitive answer to solving this problem. Yeah, big call I know, but bear with me.
The first port of call if you encounter this problem is to run composer dump-autoload
. This should result in an updated version of the file vendor/composer/autoload_classmap.php
.
If autoload_classmap.php
doesn't get updated then you may have a permissions problem, in which case you could try sudo composer dump-autoload
.
However, if autoload_classmap.php
does get updated, check that it contains an entry for your migration class (in this case CreateCodesnippetsTable
). If there is no entry for this class then you should check your composer.json
file and make sure the app/database/migrations
folder is included in the autoload section, eg:
"autoload": {
"classmap": [
"app/controllers",
"app/models",
"app/database/migrations"
]
},
This last bit is what screwed things up for me. In a misguided attempt at optimising things I pulled as much as I could out of my composer.json
file, naively thinking this would only affect web requests. It turns out this affected Artisan as well, so putting this line back in and running composer dump-autoload
fixed the problem for me.
Finally, if all that fails, then maybe there's a bug in one of the supporting libraries that is causing the problem, in which case you can try updating using composer update
or some variation thereof. However, I suspect that this will rarely be the true cause of the problem.