Skip to content

Commit 35750c5

Browse files
authored
Fix null constraint columns in add-foreign-keys template (#962)
Add default([]) filter before sort to handle cases where constraint['columns'] may be null, preventing Twig runtime errors during migration snapshot generation. Fixes #961
1 parent 85a6bc4 commit 35750c5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

templates/bake/element/add-foreign-keys.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% set statement = Migration.tableStatement(table, true) %}
22
{% set hasProcessedConstraint = false %}
33
{% for constraintName, constraint in constraints %}
4-
{%~ set constraintColumns = constraint['columns']|sort %}
4+
{%~ set constraintColumns = constraint['columns']|default([])|sort %}
55
{%~ if constraint['type'] == 'foreign' %}
66
{%~ set hasProcessedConstraint = true %}
77
{%~ set columnsList = '\'' ~ constraint['columns'][0] ~ '\'' %}

0 commit comments

Comments
 (0)