summaryrefslogtreecommitdiff
path: root/internal/db/bundb/migrations/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/bundb/migrations/util.go')
-rw-r--r--internal/db/bundb/migrations/util.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/db/bundb/migrations/util.go b/internal/db/bundb/migrations/util.go
index f20f23c3f..4a3a62b21 100644
--- a/internal/db/bundb/migrations/util.go
+++ b/internal/db/bundb/migrations/util.go
@@ -34,10 +34,24 @@ import (
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect"
"github.com/uptrace/bun/dialect/feature"
+ "github.com/uptrace/bun/dialect/pgdialect"
"github.com/uptrace/bun/dialect/sqltype"
"github.com/uptrace/bun/schema"
)
+// bunArrayType wraps the given type in a pgdialect.Array
+// if needed, which postgres wants for serializing arrays.
+func bunArrayType(db bun.IDB, arr any) any {
+ switch db.Dialect().Name() {
+ case dialect.SQLite:
+ return arr // return as-is
+ case dialect.PG:
+ return pgdialect.Array(arr)
+ default:
+ panic("unreachable")
+ }
+}
+
// doWALCheckpoint attempt to force a WAL file merge on SQLite3,
// which can be useful given how much can build-up in the WAL.
//