我的环境

go 1.18
gorm.io/driver/sqlite v1.5.4
gorm.io/gorm v1.25.4

我的代码

var db *gorm.DB

type Assets struct {
    gorm.Model
}

func init() {
    var err error
    db, err = gorm.Open(sqlite.Open("assets.db"), &gorm.Config{})
    if err != nil {
        fmt.Println("连接数据库出错:", err.Error())
        return
    }

    db.AutoMigrate(&Assets{})
}

然后我得到了这个报错

table "assets" has more than one primary key
[0.036ms] [rows:0] CREATE TABLE `assets` (`id` integer PRIMARY KEY AUTOINCREMENT,`created_at` datetime,`updated_at` datetime,`deleted_at` datetime,PRIMARY KEY (`id`))

Comment From: github-actions[bot]

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 Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: saltyfishyu

版本

gorm.io/driver/sqlite v1.4.4
gorm.io/gorm v1.24.0

同样方式创建表未报错

Comment From: sluedecke

I have the same issue. Is this a duplicate of https://github.com/go-gorm/gorm/issues/6628 ?

Comment From: github-actions[bot]

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 Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: saltyfishyu

I have the same issue. Is this a duplicate of #6628 ?

应该是的