Golang GORM 中列的自动迁移问题

Auto-migration issues with columns in Golang GORM

自动迁移问题(我认为)。我可以通过 psql 控制台得出该列不存在的结论。我可以通过 terminal/console/SQL 手动插入该列,但更喜欢通过自动迁移来解决此问题。

感谢您的阅读 and/or 操作。

终端输出:

来源:Jon Calhoun

资源:https://www.usegolang.com/

"...the short answer is that automigrate fails to run because when it adds the column and says it can't have null values this contradicts the fact that any existing records will have a null value by default. The simplest fix since you are still in a dev env is to delete all the users from your table either by dripping the entire table or by running some SQL."

非常感谢 Jon Calhoun 提供了这个简单有效的解决方案。