-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AutoMigrate函数迁移sqlite数据库表失败 #7275
Comments
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the |
There is no column named Why don't you read the error more carefully? |
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the |
原始的数据库建表语句中本身就没有please这一列。我的理解是AutoMigrate内部在解析数据库建表语句的时候,用的逗号分割的schema,导致把please误认为是一个column,而实际上不是。 如果建表语句是下面这样
AutoMigrate函数是可以迁移成功的。 |
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the |
GORM Playground Link
https://github.com/go-gorm/gorm/releases/tag/v1.25.12
Description
1.已经存在了一个sqlite3数据库,表结构已经通过sql语句被建立好了,建表语句如下:
生成一个a.db的sqlite数据库文件。
2.使用AutoMigrate函数修改表结构,go代码程序如下:
go build 生成gormtest程序
3.运行gormtest程序,报错如下
./gormtest
2024/11/12 11:41:54 table tb_levels__temp has no column named please
[0.017ms] [rows:0] INSERT INTO
tb_levels__temp
(please
,code
,0
) SELECTplease
,code
,0
FROMtb_levels
Failed to auto migrate database, error is table tb_levels__temp has no column named please, retry.
The text was updated successfully, but these errors were encountered: