From 25f3c5d9d7d2e4c339e1e60f18906de79a7be44e Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 25 Mar 2025 21:47:52 +0100 Subject: [PATCH] fix(migration): cast to text --- pkg/migration/20250323212553.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/migration/20250323212553.go b/pkg/migration/20250323212553.go index 9400656a3..d5b207de4 100644 --- a/pkg/migration/20250323212553.go +++ b/pkg/migration/20250323212553.go @@ -19,6 +19,7 @@ package migration import ( "src.techknowlogick.com/xormigrate" "xorm.io/xorm" + "xorm.io/xorm/schemas" ) func init() { @@ -28,7 +29,13 @@ func init() { Migrate: func(tx *xorm.Engine) (err error) { oldViews := []*projectViews20241118123644{} - err = tx.Where("filter not like '{%' AND filter is not null AND filter != ''").Find(&oldViews) + // PostgreSQL needs explicit casting for LIKE operations on JSON fields + if tx.Dialect().URI().DBType == schemas.POSTGRES { + err = tx.Where("filter::text not like '{%' AND filter is not null AND filter::text != ''").Find(&oldViews) + } else { + err = tx.Where("filter not like '{%' AND filter is not null AND filter != ''").Find(&oldViews) + } + if err != nil { return }