Skip to content

Commit 5a8c79c

Browse files
committed
chore(ci): add workflow to prevent temporary migrations from being merged into main
This update introduces a GitHub Actions workflow that checks for temporary migration files matching specific patterns. If such files are found in a pull request targeting main, the workflow will block the merge and provide instructions to remove temporary migrations and generate a final migration. This helps maintain migration integrity and prevents incomplete or placeholder migrations from reaching production.
1 parent 8f5f185 commit 5a8c79c

2 files changed

Lines changed: 67 additions & 1 deletion

File tree

.claude/schema_development.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,37 @@ pnpm nx verify-migrations core
7878
pnpm nx test:pgtap core
7979
```
8080

81+
## Working with Stacked PRs (Graphite)
82+
83+
When developing features across multiple stacked PRs, use temporary migrations:
84+
85+
### Each PR in Stack
86+
Follow normal development workflow (see above), but when generating migrations:
87+
```bash
88+
# Use TEMP_ prefix for non-final migrations
89+
./scripts/atlas-migrate-diff TEMP_feature_part_1 # Will create *_pgflow_TEMP_*.sql
90+
```
91+
92+
### Before Merging to Main (Top PR Only)
93+
```bash
94+
# Remove ALL temp migrations
95+
git rm -f supabase/migrations/*_pgflow_{TEMP,temp}_*.sql
96+
97+
# Regenerate as final migration (follow "Regenerating Migrations" section above)
98+
./scripts/atlas-migrate-diff actual_feature_name # No TEMP_ prefix
99+
```
100+
101+
### Why?
102+
- Each PR passes CI independently
103+
- Single clean migration ships to users
104+
- CI automatically blocks TEMP_/temp_ migrations from main
105+
81106
## Best Practices
82107

83108
**Development**: Edit schemas/*.sql first, psql iteration, test incrementally, TDD
84109
**Migrations**: Generate only (never hand-write), one per PR, descriptive names, test thoroughly, commit with schemas
85-
**Avoid**: Manual migration edits, forgetting to remove old migration, skipping hash reset, failing tests, mixing changes
110+
**Temp Migrations**: Use TEMP_ prefix for stacked PRs, remove before final merge, CI enforces this
111+
**Avoid**: Manual migration edits, forgetting to remove old migration, skipping hash reset, failing tests, mixing changes, merging temp migrations to main
86112

87113
## Troubleshooting
88114

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Prevent Temporary Migrations on Main
2+
on:
3+
pull_request:
4+
branches: [main]
5+
6+
jobs:
7+
block-temp-migrations:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Check for temporary migrations
13+
run: |
14+
# Check for any temp migrations (both TEMP and temp)
15+
shopt -s nullglob
16+
temp_migrations=(pkgs/core/supabase/migrations/*_pgflow_TEMP_*.sql pkgs/core/supabase/migrations/*_pgflow_temp_*.sql)
17+
18+
if [ ${#temp_migrations[@]} -gt 0 ]; then
19+
echo "::error::❌ Temporary migrations found! These cannot be merged to main."
20+
echo -e "\033[31m"
21+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
22+
echo "❌ TEMPORARY MIGRATIONS DETECTED - CANNOT MERGE TO MAIN"
23+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
24+
echo ""
25+
echo "Found temporary migrations:"
26+
printf ' • %s\n' "${temp_migrations[@]}"
27+
echo ""
28+
echo "TO FIX: Remove temp migrations and generate final migration:"
29+
echo ""
30+
echo " git rm -f pkgs/core/supabase/migrations/*_pgflow_TEMP_*.sql"
31+
echo " git rm -f pkgs/core/supabase/migrations/*_pgflow_temp_*.sql"
32+
echo " cd pkgs/core"
33+
echo " ./scripts/atlas-migrate-hash --yes"
34+
echo " ./scripts/atlas-migrate-diff your_feature_name"
35+
echo ""
36+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
37+
echo -e "\033[0m"
38+
exit 1
39+
fi
40+
echo "✅ No temporary migrations found"

0 commit comments

Comments
 (0)