Golang GORM 中列的自动迁移问题
Auto-migration issues with columns in Golang GORM
自动迁移问题(我认为)。我可以通过 psql 控制台得出该列不存在的结论。我可以通过 terminal/console/SQL 手动插入该列,但更喜欢通过自动迁移来解决此问题。
感谢您的阅读 and/or 操作。
终端输出:
- 启动 Web 服务器:“(pq: 列 "password_hash" 包含空值 值)"
- 提交POST:“(pq:关系"accounts"的列"password_hash"不存在)”
来源:Jon Calhoun
"...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 提供了这个简单有效的解决方案。