Fixing Golang GORM AutoMigrate postgresql error
With the release of new pg driver AutoMigrate is throwing errors...
When getting error:
pq: got 2 parameters but the statement requires 1
- need to downgrade the driver
I had to downgrade in recent project from
gorm.io/driver/postgres v1.5.11
to
gorm.io/driver/postgres v1.4.0
After doing some googling I’ve found this ref of Feb 2024
gorm@1.25.7 is not compatible with postgres@1.5.6 driver. #167
also from reddit:
I always check mysql,redis,and mongo thoroughly before releasing an update.
For postgres, I only did first migration test which always worked
but didn't test with rerun.
Surprisingly, the last functioning postgres driver version is
gorm.io/driver/postgres v1.4.0!
also another issue, but looks like it’s bug is not unique: https://github.com/go-gorm/gorm/issues/5409
after upgrade from v1.23.4 to v1.23.5 #5409
pq: got 1 parameters but the statement requires 0
ok…