Skip to content

Commit

Permalink
feat: reenable db prepared statements for kafka migrations
Browse files Browse the repository at this point in the history
the bug related to db prepared statements has been fixed
on gorm.io/driver/postgres v1.4.5. We are now using that version
so this reenables db prepared statements for kafka migrations
  • Loading branch information
miguelsorianod committed Mar 14, 2023
1 parent 5aac24c commit 7ac1a30
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions internal/kafka/internal/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,7 @@ var migrations = []*gormigrate.Migration{
}

func New(dbConfig *db.DatabaseConfig) (*db.Migration, func(), error) {
// We need to disable SQL Prepared Statements when performing Kafka DB
// migrations due to caching issues with them in gorm that end up causing
// errors. It seems the reasons for the issues might be a potential bug in
// gorm, as when using previous gorm versions (v1.21.7) the issues didn't
// happen.
// A GitHub issue has been opened to the gorm project
// reporting this: https://github.com/go-gorm/gorm/issues/5737
// If it is confirmed to be an issue and gorm project fixes it we should
// update this code accordingly when the fix is applied.
dbConfigWithDisabledPreparedStatements := dbConfig.DeepCopy()
dbConfigWithDisabledPreparedStatements.EnablePreparedStatements = false
return db.NewMigration(dbConfigWithDisabledPreparedStatements, &gormigrate.Options{
return db.NewMigration(dbConfig, &gormigrate.Options{
TableName: "migrations",
IDColumnName: "id",
IDColumnSize: 255,
Expand Down

0 comments on commit 7ac1a30

Please sign in to comment.