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
V1.23.x AutoMigrate Bug(first ok, but when run more than once, will fire error). #5175
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 |
I'm having a similar issue with SQLite, see muety/wakapi#346. |
I'm also getting errors with AutoMigrate:
|
For PG,it looks like the reason is sql |
I am having a similar issue, I think related, but with a simpler case. Trying to use AutoMigrate on postgres with any prefix works the first time, but not the 2nd time. Same issue when defining TableName() or when using NamePrefix config. type Person struct {
ID int
Name string
}
func (Person) TableName() string { return "foo.Person" }
func main() {
const dsn = "host=db user=usr password=pass dbname=db port=5432 sslmode=disable"
db, _ := gorm.Open(postgres.Open(dsn), &gorm.Config{
// NamingStrategy: schema.NamingStrategy{
// TablePrefix: "foo.",
// },
})
db.Exec(`CREATE SCHEMA IF NOT EXISTS "foo";`)
if err := db.AutoMigrate(&Person{}); err != nil {
panic(err)
}
} The first run works well, the table gets created in the proper schema with all the right fields, but the runs after that fail with:
The same code without the schema prefix or with |
Had the same behavior as @creack with Postgres. |
Same issue this side with Postgres. Reverting back down to 1.22 fixes things. |
Sorry for the issue, please upgrade mysql/postgres/sqlserver driver to support it. |
I think this is still a case in the latest version for Postgres and third auto migration (the second works fine): |
Is there a way to turn off AutoMigrate ? |
GORM Playground Link
go-gorm/playground#451
Description
in the gorm version 1.23.x, first AutoMigrate can run ok, but when you call AutoMigrate more than once, it's will panic.
The text was updated successfully, but these errors were encountered: