Commit d407dd7
feat(detector): SQL/migration detector + SQL_ENTITY NodeKind (#48)
Adds a SqlMigrationDetector under detector/sql that extracts schema-level
entities (tables, views, schemas) from raw SQL DDL and framework-specific
migration files: Flyway (V*__*.sql), Liquibase (XML + YAML), Alembic
(versions/*.py with alembic/op marker guard), Rails (db/migrate/*.rb),
and Prisma (migrations/*/migration.sql). Path/marker discriminators
prevent false positives on arbitrary .py/.rb/.xml/.yml.
Enum additions:
- NodeKind.SQL_ENTITY (new): schema-level table/view/schema node,
distinct from the code-level ENTITY (JPA/ORM) kind.
- EdgeKind.REFERENCES_TABLE (new): any node (JPA ENTITY, ORM model,
raw SQL_ENTITY) -> SQL_ENTITY, pairing with existing ORM detectors.
- EdgeKind.MIGRATES (reused): MIGRATION -> SQL_ENTITY. Unused in
production code elsewhere; only referenced by ModelCoverageTest.
LayerClassifier: SQL_ENTITY classified as `infra`.
Deterministic output (sorted by id on emit); detector is stateless.
ALTER TABLE ADD COLUMN enriches the owning entity via columns_added
property; did not model columns as child nodes to keep graph size
reasonable. DROP TABLE is skipped with a debug log.
Tests: 16 new tests covering positive paths (raw SQL, Flyway, Alembic,
Liquibase XML, Liquibase YAML, Rails, Prisma), negative paths (plain
.py/.yaml, Alembic path without marker), determinism, and DDL variants
(DROP, CREATE INDEX, ALTER TABLE). Test count 3278 -> 3294.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 84e8e65 commit d407dd7
9 files changed
Lines changed: 937 additions & 11 deletions
File tree
- src
- main/java/io/github/randomcodespace/iq
- analyzer
- detector/sql
- model
- test/java/io/github/randomcodespace/iq
- detector/sql
- model
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
Lines changed: 542 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
0 commit comments