fix(migration): cast to text

This commit is contained in:
kolaente 2025-03-25 21:47:52 +01:00
parent d615e2038b
commit 25f3c5d9d7
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 8 additions and 1 deletions

View File

@ -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
}