From ec325fee141c1e9757144a0a4094061b56839b78 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 12 May 2023 14:33:40 +0200 Subject: [chore] Update a bunch of database dependencies (#1772) * [chore] Update a bunch of database dependencies * fix lil thing --- internal/db/bundb/bundb.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'internal/db/bundb') diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go index ecf8752ea..f095d1728 100644 --- a/internal/db/bundb/bundb.go +++ b/internal/db/bundb/bundb.go @@ -33,8 +33,8 @@ import ( "codeberg.org/gruf/go-bytesize" "github.com/google/uuid" - "github.com/jackc/pgx/v4" - "github.com/jackc/pgx/v4/stdlib" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/stdlib" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db/bundb/migrations" @@ -94,14 +94,11 @@ func doMigration(ctx context.Context, db *bun.DB) error { } group, err := migrator.Migrate(ctx) - if err != nil { - if err.Error() == "migrate: there are no any migrations" { - return nil - } + if err != nil && !strings.Contains(err.Error(), "no migrations") { return err } - if group.ID == 0 { + if group == nil || group.ID == 0 { log.Info(ctx, "there are no new migrations to run") return nil } @@ -132,9 +129,8 @@ func NewBunDBService(ctx context.Context, state *state.State) (db.DB, error) { return nil, fmt.Errorf("database type %s not supported for bundb", t) } - // Add database query hook + // Add database query hooks. conn.DB.AddQueryHook(queryHook{}) - if config.GetTracingEnabled() { conn.DB.AddQueryHook(tracing.InstrumentBun()) } @@ -431,7 +427,6 @@ func deriveBunDBPGOptions() (*pgx.ConnConfig, error) { cfg.TLSConfig = tlsConfig } cfg.Database = database - cfg.PreferSimpleProtocol = true cfg.RuntimeParams["application_name"] = config.GetApplicationName() return cfg, nil -- cgit v1.3