summaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-03-09 16:44:12 +0100
committerLibravatar GitHub <noreply@github.com>2025-03-09 16:44:12 +0100
commit35e94c8abd3767eb44620cdf7246ba04f9d9252c (patch)
tree9f3b98d9e2f47914d4fc7d5a78cd53e3e749771a /internal/db
parent[chore] update links in CONTRIBUTING.md (#3881) (diff)
downloadgotosocial-35e94c8abd3767eb44620cdf7246ba04f9d9252c.tar.xz
[bugfix] Fix `length for type varchar must be at least 1` on Postgres (#3885)
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/bundb/migrations/util.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/internal/db/bundb/migrations/util.go b/internal/db/bundb/migrations/util.go
index 6ffcdd09d..b8a60417d 100644
--- a/internal/db/bundb/migrations/util.go
+++ b/internal/db/bundb/migrations/util.go
@@ -253,9 +253,14 @@ func getBunColumnDef(db bun.IDB, rtype reflect.Type, fieldName string) (string,
} else {
buf = append(buf, sqltype.VarChar...)
}
- buf = append(buf, "("...)
- buf = strconv.AppendInt(buf, int64(d.DefaultVarcharLen()), 10)
- buf = append(buf, ")"...)
+
+ // Only specify varchar length for dialects
+ // where specifying VARCHAR length is mandatory.
+ if dvl := d.DefaultVarcharLen(); dvl != 0 {
+ buf = append(buf, "("...)
+ buf = strconv.AppendInt(buf, int64(dvl), 10)
+ buf = append(buf, ")"...)
+ }
}
// Append not null definition if field requires.