tiagorlampert / CHAOS

:fire: CHAOS is a free and open-source Remote Administration Tool that allow generate binaries to control remote operating systems.
MIT License
2.31k stars 498 forks source link

fix: migrator error of gorm on second run #137

Closed WaferJay closed 1 month ago

WaferJay commented 2 months ago

See go-gorm/gorm#5409.

The solution is referenced from https://github.com/go-gorm/gorm/issues/5409#issuecomment-1151949457

db, err := gorm.Open(postgres.New(postgres.Config{
  DSN: "host=localhost user=gorm password=gorm dbname=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai", // data source name, refer https://github.com/jackc/pgx
  PreferSimpleProtocol: true, // disables implicit prepared statement usage. By default pgx automatically uses the extended protocol
}), &gorm.Config{})

Have a nice day. :-)