Alerting: Collate alert_rule.namespace_uid column as binary (#115152)

Alerting: Collate namespace_uid column as binary
This commit is contained in:
Alexander Akhmetov
2025-12-11 16:05:13 +01:00
committed by GitHub
parent 4ab198b201
commit 73bcfbcc74
2 changed files with 12 additions and 0 deletions
@@ -165,5 +165,7 @@ func (oss *OSSMigrations) AddMigration(mg *Migrator) {
ualert.AddStateAnnotationsColumn(mg)
ualert.CollateBinAlertRuleNamespace(mg)
ualert.CollateBinAlertRuleGroup(mg)
}
@@ -0,0 +1,10 @@
package ualert
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
// CollateBinAlertRuleNamespace ensures that namespace_uid column collates in the same way go sorts strings.
func CollateBinAlertRuleNamespace(mg *migrator.Migrator) {
mg.AddMigration("ensure namespace_uid column sorts the same way as golang", migrator.NewRawSQLMigration("").
Mysql("ALTER TABLE alert_rule MODIFY namespace_uid VARCHAR(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL;").
Postgres(`ALTER TABLE alert_rule ALTER COLUMN namespace_uid SET DATA TYPE varchar(40) COLLATE "C";`))
}