gormigrate
gormigrate copied to clipboard
Migration breaks in gorm.io/gorm 1.25.6 when using pgx driver for PostgreSQL
Specifically the change https://github.com/go-gorm/gorm/compare/v1.25.5...v1.25.6#diff-7539aa7c170a85138fa67c7846b65fda95a51169bcf8637d5961ea570307d755 will end up with an error LastInsertId is not supported by this driver
.
It seems to be the hasReturning(*gorm.DB,bool)(bool, gorm.ScanMode)
in
gorm.io/gorm/callbacks/helper.go:96
that breaks existing functionality.
This file doesn't appear to be changed in the gorm.io version upgrade.
Might it look like that Gorm has started to require a RETURNING
on the kind of INSERT
/Create()
that gormigrate perform?
Versions: Go 1.21.5 linux/amd64 Gorm.io 1.25.6 Gormigrate 2.1.1 (v2 packages)
Works with versions: Go 1.21.5 linux/amd64 Gorm.io 1.25.5 Gormigrate 2.1.1 (v2 packages)
I made the issue to gorm already, you can see it here https://github.com/go-gorm/gorm/issues/6812.
The PR author is aware of it and said he is going to do a fix.
Same here. Rolling back to 1.25.5 fixes the issue here as well.
Also reported to gorm.
Hello, I made a fix for this. I don't know if my Pull Request will be merged but I haven't created a branch from this fix to allow making a replace in my go.mod file.
Here is the patch commit:
replace github.com/go-gormigrate/gormigrate/v2 v2.1.1 => github.com/oxyno-zeta/gormigrate/v2 v2.0.0-20240318121440-b7e1f70e30f6
Here is the diff for this specific branch: https://github.com/go-gormigrate/gormigrate/compare/master...oxyno-zeta:gormigrate:issue-217-replace
Have a good day !
@jhberges Thank you for reporting issue, @oxyno-zeta thank for the fix. It's included in v2.1.2