@@ -102,14 +102,37 @@ jobs:
102102 - name : Verify existing migrations are not modified or deleted
103103 run : |
104104 BASE_REF="${{ steps.base.outputs.base_ref }}"
105- CHANGED=$(git diff --name-only --diff-filter=MD origin/$BASE_REF...HEAD -- migrations/)
105+ CHANGED=$(git diff --name-only --diff-filter=MD origin/$BASE_REF...HEAD -- migrations/ | grep -E 'Version[0-9]{14}\.php$' || true )
106106 if [ -n "$CHANGED" ]; then
107107 echo "Error: The following existing migrations were modified or deleted:"
108108 echo "$CHANGED"
109109 exit 1
110110 fi
111111 echo "No existing migrations were modified or deleted."
112112
113+ - name : Verify new migrations follow naming convention
114+ run : |
115+ BASE_REF="${{ steps.base.outputs.base_ref }}"
116+ NEW_FILES=$(git diff --name-only --diff-filter=A origin/$BASE_REF...HEAD -- migrations/ | grep '\.php$' || true)
117+ if [ -z "$NEW_FILES" ]; then
118+ echo "No new migrations added."
119+ exit 0
120+ fi
121+
122+ FAILED=false
123+ for file in $NEW_FILES; do
124+ if ! echo "$file" | grep -qE 'Version[0-9]{14}\.php$'; then
125+ echo "Error: $file does not follow the migration naming convention (Version{14digits}.php)"
126+ FAILED=true
127+ else
128+ echo "OK: $file"
129+ fi
130+ done
131+
132+ if [ "$FAILED" = true ]; then
133+ exit 1
134+ fi
135+
113136 - name : Verify new migrations have higher version numbers than existing migrations
114137 run : |
115138 BASE_REF="${{ steps.base.outputs.base_ref }}"
@@ -128,11 +151,10 @@ jobs:
128151
129152 FAILED=false
130153 for file in $NEW_MIGRATIONS; do
131- VERSION=$(echo "$file" | grep -oE '[0-9]{14}')
132- if [ -z "$VERSION" ]; then
133- echo "Warning: Could not extract version number from $file"
154+ if ! echo "$file" | grep -qE 'Version[0-9]{14}\.php$'; then
134155 continue
135156 fi
157+ VERSION=$(echo "$file" | grep -oE '[0-9]{14}')
136158 if [ "$VERSION" -le "$BASE_MAX" ]; then
137159 echo "Error: $file has version $VERSION which is not higher than the existing maximum $BASE_MAX"
138160 FAILED=true
0 commit comments