Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: handle edge cases in migration (null, empty array) (#17978)

h3n4l934ab7619cc0
diff --git a/backend/migrator/migration/3.12/0002##migrate_statement_where_require_rule.sql b/backend/migrator/migration/3.12/0002##migrate_statement_where_require_rule.sql
index d13d16c57c..81f13809d9 100644
--- a/backend/migrator/migration/3.12/0002##migrate_statement_where_require_rule.sql
+++ b/backend/migrator/migration/3.12/0002##migrate_statement_where_require_rule.sql
@@ -46,6 +46,9 @@ SET payload = jsonb_set(
)
)
WHERE payload ? 'sqlReviewRules'
+ -- Only process if sqlReviewRules is an array (not null, not scalar)
+ AND jsonb_typeof(payload->'sqlReviewRules') = 'array'
+ -- Only process if there's at least one statement.where.require rule
AND EXISTS (
SELECT 1
FROM jsonb_array_elements(payload->'sqlReviewRules') AS rule