Skip to content

Commit 91a5a92

Browse files
committed
Add initial agent guidelines for generating migrations
1 parent 8a1280e commit 91a5a92

3 files changed

Lines changed: 48 additions & 4 deletions

File tree

.github/workflows/database.yaml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

migrations/AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Agent guidelines for Dirigent development: migrations/
2+
3+
## Generate new migrations
4+
5+
To generate a new migration, execute the `symfony console doctrine:migrations:diff --nowdoc --formatted` command.
6+
7+
## Coding style
8+
9+
- Migration files must follow the naming convention of `Version[0-9]{14}.php`.
10+
- Migrations must have a non-empty description.
11+
- Queries should be wrapped in nowdoc by default. Only if a PHP variable is used in the query is it allowed to be wrapped in heredoc.
12+
13+
## Required columns
14+
15+
If a required (non-nullable) column is added to the schema, add it with the following queries:
16+
17+
1. Add a nullable column.
18+
2. Set a default value for every row in the table.
19+
3. Remove the nullable flag from the column.

migrations/CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Agent guidelines for Dirigent development in Claude Code: migrations/
2+
3+
@AGENTS.md

0 commit comments

Comments
 (0)