Skip to content

Commit de9363b

Browse files
committed
docs(agents): document SQL migration checker in AGENTS.md
- Add SQL Migration Checking section with usage examples - Update Common Make Targets table with new sql-check targets - Enhance Development Loop with SQL check step - Add SQL check commands to Common Commands appendix - Document severity levels and when to use the checker
1 parent 2e0c371 commit de9363b

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,10 @@ The API will be available at `http://localhost:8080`.
746746
| `make migrate-create NAME=x` | Create new migration |
747747
| `make tidy` | Run `go mod tidy` |
748748
| `make all` | Full pipeline: tidy → format → lint → test → build |
749+
| `make sql-check` | Run SQL migration audit on all .sql files |
750+
| `make sql-check-ci` | Run SQL check with CI-friendly output |
751+
| `make sql-check-one FILE=x` | Check a single migration file |
752+
| `make sql-audit-report` | Generate comprehensive SQL audit report |
749753

750754
### Development Loop
751755

@@ -754,7 +758,43 @@ The API will be available at `http://localhost:8080`.
754758
3. **Test** with `make test` or `make test-one`
755759
4. **Format** with `make format`
756760
5. **Lint** with `make lint` or `make lint-fix`
757-
6. **Commit** (pre-commit hooks run automatically)
761+
6. **Check SQL migrations** with `make sql-check` (for new .sql files)
762+
7. **Commit** (pre-commit hooks run automatically)
763+
764+
### SQL Migration Checking
765+
766+
The project includes a comprehensive SQL migration checker that performs strict static analysis on PostgreSQL `.sql` files. It detects:
767+
768+
- **🔴 CRITICAL**: SQL injection vulnerabilities, missing migration pairs
769+
- **🟡 WARNING**: Missing FK policies, missing indexes, non-idempotent statements, naming issues
770+
- **🔵 INFO**: Missing audit fields, text constraints, optimization suggestions
771+
772+
```bash
773+
# Check all migrations
774+
make sql-check
775+
776+
# Check a single file
777+
make sql-check-one FILE=000009_create_user_movements.up.sql
778+
779+
# CI-friendly output format
780+
make sql-check-ci
781+
782+
# Generate detailed audit report
783+
make sql-audit-report
784+
```
785+
786+
**When to use:**
787+
- Before committing new migration files
788+
- In CI/CD pipeline to block problematic migrations
789+
- When auditing existing migrations for technical debt
790+
- During code reviews of database schema changes
791+
792+
**Example output:**
793+
```
794+
🟡 WARNING: 000009_create_user_movements.up.sql:15 - Table name uses PascalCase, consider snake_case
795+
🟡 WARNING: 000003_create_organizations.up.sql - Foreign key column 'verified_by_user_id' needs index
796+
🔵 INFO: 000005_create_refresh_tokens.up.sql - Consider adding updated_at TIMESTAMPTZ with trigger
797+
```
758798

759799
### Reindexing Meilisearch
760800

@@ -1242,6 +1282,11 @@ make format # Format code
12421282
make lint # Run linter
12431283
make lint-fix # Auto-fix issues
12441284

1285+
# SQL Migration Checks
1286+
make sql-check # Audit all SQL migrations
1287+
make sql-check-ci # CI-friendly format
1288+
make sql-check-one FILE=x # Check single file
1289+
12451290
# Testing
12461291
make test # Run all tests
12471292
make test-race # With race detector

0 commit comments

Comments
 (0)