var db *gorm.DB db, err = gorm.Open(mysql.Open(dbAddress), &gorm.Config{})
db.AutoMigrate(Camera{}) db.AutoMigrate(Sequence{})
你好,AutoMigrate报错,Error 1050: Table 'Sequences' already exists
[0.121ms] [rows:0] CREATE TABLE Sequences (SequenceID bigint AUTO_INCREMENT,Image longtext,UserPwd bigint,Brand bigint,Status bigint,ID longtext,Birthday bigint,Sex boolean,PRIMARY KEY (SequenceID))
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 2 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: JonasDoe
I've stumbled upon the same issue under these conditions:
- Using the mysql Dialector
- The table does exist already
- The gorm Table is set with schema name, e.g. myschema.mytable
- The schema is not set in the underlying mysql connection
The automigration won't fail because of a missing schema (it probably accepted my dot-notation), but the HasTable will check whether the table mytable exists in the Migrator's currentDatabase, which is not myschema but INFORMATION_SCHEMA. So no table is found, the Migrator attempts to create the table anew, and fails.
Comment From: priceou
说错了不是单引号是backquote符号 `
Comment From: JonasDoe
I just realized that the details layed out in my previous post might got missed b/c the issue was already stale/closed, so I'll ping @jinzhu Sry for the harrassment :see_no_evil: