Reputation: 1837
when I ran
php artisan migrate:reset
I got
[ErrorException]
include(app/database/migrations/2014_08_06_120900_alter_xxx_table.php): failed to
open stream: No such file or directory
But I don't have that php file, I just have another file named
2014_08_06_121048_alter_xxx_table.php
And the migrations
table in mysql has only
2014_08_06_121048_alter_xxx_table.php
but not
2014_08_06_120900_alter_xxx_table.php
Now I can't reset my database. What can I do about this?
Upvotes: 29
Views: 29907
Reputation: 2193
This command works
php artisan optimize
php artisan migrate:rollback
Upvotes: 1
Reputation: 2193
Undo the actions the migration done on the database. Then look at the migrations table and remove the row relating to the file you deleted.
After that you might then need to run
composer dump-autoload
Upvotes: 1
Reputation: 334
Use this command. It worked for me.
php artisan migrate:rollback
Upvotes: 0
Reputation: 1
Probably you should manually create folder migrations. Then composer update. And run migrations
Upvotes: 0
Reputation: 167
This same issue occurred to me while creating a sessions table. Basically it cannot find the path app/database/migrations/2014_08_06_120900_alter_xxx_table.php.
One possibility is that your database/migrations path is not app/database/migrations. So first you should find your correct path for database/migrations. I was using a october cms framework on top of it and found my path was "modules/system/database/migrations".
You need to open the SessionTableCommand.php
in vendor/laravel/framework/src/Illuminate/Session/Console path
. On the line #77 you will find $path variable. Change that to your path for database/migrations.
In my case line 77 looked like this:
$path = 'modules/system/database/migrations';
These errors happen mostly because of incorrect path for the file or directory.
Upvotes: 0
Reputation: 1
Look for the file autoload_classmap.php
in /vendor/composer
.
Open the file and edit the following:
In return array{ }
remove the existing table.php
files.
Example:
'CreatePasswordResetsTable'
=> $baseDir . '/database/migrations/2014_10_12_100000_create_password_resets_table.php'
,
'CreateUsersTable'
=> $baseDir . '/database/migrations/2014_10_12_000000_create_users_table.php'
,
I removed the above two lines from that array and again executed php artisan make:User -m
and it created model as well as migration.
Upvotes: 0
Reputation: 1099
First:
composer dump-autoload
Then make de rollback.
This work for me...
composer dump-autoload
php artisan migrate:rollback
Upvotes: 104
Reputation: 149
php artisan dump-autoload
solve the same problem of mine.. rather than change manually
Upvotes: 8
Reputation: 1837
Deleting the row with 2014_08_06_121048_alter_xxx_table in table migrations
didn't really solve the problem. When I run php artisan migrate:reset
again, the problem comes again too.
Finally I find the essential reason myself. Due to some reason maybe some wrong commands, wrong filename had been written into
./vendor/composer/autoload_classmap.php
So I correct the filename in this file, everything works well now.
Upvotes: 6
Reputation: 60058
It sounds like you did a migration, then later on deleted a migration file before you did the rollback. So now Laravel is not sure how to rollback your database.
Easiest solution (since you are reseting anyway) is to manually clear all the tables from your database, including the migration table.
Then just run php artisan migrate
and it will install the table and run your migrations.
In the future you should not manually alter your migration files unless you have rollbacked first.
Upvotes: 3