laravel php artisan migrate:reset 无法打开流:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25237415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php artisan migrate:reset failed to open stream: No such file or directory
提问by worldask
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
但是我没有那个 php 文件,我只有另一个名为的文件
2014_08_06_121048_alter_xxx_table.php
And the migrations
table in mysql has only
而migrations
mysql中的表只有
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?
现在我无法重置我的数据库。我该怎么办?
回答by Ferticidio
First:
第一的:
composer dump-autoload
Then make de rollback.
然后进行回滚。
This work for me...
这项工作对我来说...
composer dump-autoload
php artisan migrate:rollback
回答by Andry Yosua
php artisan dump-autoload
solve the same problem of mine.. rather than change manually
解决我的同样问题..而不是手动更改
回答by worldask
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.
删除表中带有 2014_08_06_121048_alter_xxx_table 的行migrations
并没有真正解决问题。当我php artisan migrate:reset
再次运行时,问题也再次出现。
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.
所以我更正了这个文件中的文件名,现在一切正常。
回答by Laurence
It sounds like you did a migration, then later on deleted a migration file beforeyou did the rollback. So now Laravel is not sure howto rollback your database.
听起来您进行了迁移,然后在进行回滚之前删除了迁移文件。所以现在 Laravel 不确定如何回滚你的数据库。
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.
然后只需运行php artisan migrate
,它将安装表并运行您的迁移。
In the future you should not manually alter your migration files unless you have rollbacked first.
将来,除非先回滚,否则不应手动更改迁移文件。
回答by Bijaya Kumar Oli
This command works
此命令有效
php artisan optimize
php artisan migrate:rollback
回答by Bijaya Kumar Oli
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
回答by Neha Pardeshi
Look for the file autoload_classmap.php
in /vendor/composer
.
Open the file and edit the following:
查找文件autoload_classmap.php
在/vendor/composer
。打开文件并编辑以下内容:
In return array{ }
remove the existing table.php
files.
在return array{ }
删除现有table.php
文件。
Example:
例子:
'CreatePasswordResetsTable'
=> $baseDir . '/database/migrations/2014_10_12_100000_create_password_resets_table.php'
,
'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'
,
'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.
我从该数组中删除了上述两行并再次执行php artisan make:User -m
,它创建了模型以及迁移。
回答by Nivedita Velagaleti
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:
在创建会话表时,我也遇到了同样的问题。基本上它找不到路径 app/database/migrations/2014_08_06_120900_alter_xxx_table.php。一种可能性是您的数据库/迁移路径不是 app/database/migrations。所以首先你应该找到数据库/迁移的正确路径。我在它上面使用了 october cms 框架,发现我的路径是“模块/系统/数据库/迁移”。您需要SessionTableCommand.php
在vendor/laravel/framework/src/Illuminate/Session/Console path
. 在#77 行你会发现 $path 变量。将其更改为您的数据库/迁移路径。在我的例子中,第 77 行看起来像这样:
$path = 'modules/system/database/migrations';
These errors happen mostly because of incorrect path for the file or directory.
这些错误的发生主要是因为文件或目录的路径不正确。
回答by vishal pardeshi
Use this command. It worked for me.
使用此命令。它对我有用。
php artisan migrate:rollback
回答by andu
php artisan dump-autoload
It do well in windows10.
它在 windows10 中表现良好。