Laravel 迁移未定义索引

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39616952/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:31:52  来源:igfitidea点击:

Laravel migration undefined index

laravelmigration

提问by Sazrit Mustafa

I am using Laravel 5.3.I deleted one of my migration files name 'feature' and everything related to it very carefully like its id from other tables etc.then i manually deleted the table from database.But now while i'm running the command "php artisan migrate:refresh".It's showing error exception with 'undefined index:***_create_features_table'.And when I'm running just 'php artisan migrate'.it shows that it was successful and all the tables successfully appear in the database.but then when i run migrate:refresh all the table disappears.what should i do to completely delete the migration file?

我正在使用 Laravel 5.3。我删除了一个名为“功能”的迁移文件以及与之相关的所有内容,例如其他表中的 ID 等。然后我从数据库中手动删除了该表。但是现在我正在运行命令“php artisan migrate:refresh”。它显示错误异常,“未定义索引:***_create_features_table”。当我只运行“php artisan migrate”时,它表明它成功了,所有表都成功出现在database.but 然后当我运行 migrate:refresh 所有表都消失了。我应该怎么做才能完全删除迁移文件?

回答by Manish

Try this.

尝试这个。

First Manually delete the migration file under app/database/migrations/my_migration_file_name.php

首先手动删除下的迁移文件 app/database/migrations/my_migration_file_name.php

Reset the composer autoload files: composer dump-autoload

重置 Composer 自动加载文件: composer dump-autoload

Modify your database: Remove the last entry from the migrations table

修改您的数据库:从数据库中删除最后一个条目 migrations table

回答by Sazrit Mustafa

Here is what I did.I cleared all the data from the database including all tables and then ran 'php artisan migrate'..that is how i made it work..But i am looking for a better solution which will not need to delete everything from the database.

这是我所做的。我从数据库中清除了所有数据,包括所有表,然后运行“php artisan migrate”..这就是我让它工作的方式..但我正在寻找一个不需要删除的更好的解决方案数据库中的所有内容。

回答by tyoc213

Try check that you have the correct migrations first

首先尝试检查您是否有正确的迁移

php artisan migrate:status

php artisan migrate:status

Then you can try something like

然后你可以尝试类似的东西

php artisan migrate:refresh --step=1

php artisan migrate:refresh --step=1

And check again the status.

并再次检查状态。

回答by Adam Kozlowski

If you have Undefined indexerror and your migration was made with --path option, then add to your ModuleServiceProvierboot()method:

如果您有Undefined index错误并且您的迁移是使用 --path 选项进行的,请添加到您的ModuleServiceProvierboot()方法中:

$this->loadMigrationsFrom(base_path('database/migrations/directory-name'));