Laravel migrate:fresh 不会删除表,然后显示没有要迁移的内容。

huangapple go评论64阅读模式
英文:

Laravel migrate:fresh not dropping tables, then says nothing to migrate

问题

这是一个现有的项目,我过去经常使用php artisan migrate:fresh命令,但今天早上它突然出现了无法工作的问题。

我真的很困惑。

当我运行migrate:fresh时,我可以在终端看到以下输出:

  Dropping all tables........................................................ 13ms DONE

   INFO  Nothing to migrate.

但实际上它并没有删除任何内容。所有的表都还在,迁移表也有数据,所以它不会执行任何操作。

事实上什么都没有改变,但突然就无法工作了。

环境详细信息:

Laravel 9.52
PHP 8.2
MacOS 13.3.1
Postgres 15.2

非常感谢任何帮助。

当我手动删除数据库并重新创建时,它可以正常迁移。

到目前为止,我已经尝试了清除缓存、倒入自动加载等操作,但都没有任何效果。

英文:

this is an existing project and I used to use php artisan migrate:fresh command a lot, this morning it suddenly stopped working for no reason.

I am really confused.

When I run migrate:fresh I can see this output in the terminal:

  Dropping all tables........................................................ 13ms DONE

   INFO  Nothing to migrate.

but it isn't actually dropping anything. All the tables are there and migrations table is populated so it won't do anything more.

Literally nothing has changed and it suddenly stopped working.

Environment details:

Laravel 9.52
PHP 8.2
MacOS 13.3.1
Postgres 15.2

Any help greatly appreciated

It migrates fine when I delete database and re-create it manually.

So far I have tried clearing cache, dumping autoload, etc. but it makes no difference.

答案1

得分: 0

在Laravel中,migrate:fresh命令旨在删除所有表并从头重新运行所有迁移。然而,它依赖于迁移表来确定哪些迁移已经被应用。

我认为你的迁移表与数据库的实际状态不同步。如果表格被手动修改或者迁移文件被修改或删除而没有使用Laravel的迁移系统,就会发生这种情况。

为了解决这个问题,你可以尝试通过运行以下命令手动重置迁移表:

php artisan migrate:reset

重置迁移表后,你可以尝试再次运行migrate:fresh

希望我的回答给你一些提示。

英文:

In Laravel, the migrate:fresh command is designed to drop all tables and re-run all migrations from scratch. However, it relies on the migrations table to determine which migrations have been applied.

I think your migrations table are out of sync with the actual state of the database. This can happen if the table was modified manually or if a migration file was modified or deleted without using Laravel's migration system.

To resolve this, you can try manually resetting the migrations table by running the following command:

php artisan migrate:reset

After resetting the migrations table, you can attempt to run migrate:fresh again.

Hope my answer give you a hint.

答案2

得分: 0

已解决的方案很简单 - 我已将以下行添加到我的配置文件 config/database.php 中的默认连接设置中:

'schema' => 'public',
英文:

OK the solution was simple - I have added the following line to my default connection settings in config/database.php:

'schema' => 'public',

huangapple
  • 本文由 发表于 2023年6月22日 17:05:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76530242.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定