Commit a214a9d
fix: fail closed on DDL the migration risk parser doesn't fully understand
Three classification bugs in DdlStatementParser shared one root cause:
branches assumed rather than verified what the parse tree contained.
- Multi-statement SQL: parse() kept only the first statement and silently
discarded the rest, so a hidden DROP TABLE riding after a harmless ALTER
reported SAFE while Postgres executed both. Switch to parseStatements()
and require exactly one statement, matching the existing multi-clause guard.
- DROP CONSTRAINT shared operation=DROP with DROP COLUMN and was reported as
DROP_COLUMN (wrong operation, false "VACUUM reclaims it" reason, and locks
missing the referenced table). Gate DROP_COLUMN on getColumnName() actually
being set; anything else falls through to UNKNOWN.
- ALTER COLUMN ... DROP NOT NULL fell into the same weak ALTER branch as a
real type change and was reported as ALTER_COLUMN_TYPE with rewritesTable=
true, though it is metadata-only. No existing rule models it correctly
(SET_NOT_NULL's rule is specific to adding the constraint), so it now
returns UNKNOWN rather than a confident wrong answer.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent c288004 commit a214a9d
2 files changed
Lines changed: 57 additions & 3 deletions
File tree
- backend/src
- main/java/com/dbaagent/service/migration
- test/java/com/dbaagent/service/migration
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
75 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| |||
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
117 | 128 | | |
118 | 129 | | |
119 | 130 | | |
| |||
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
123 | 166 | | |
0 commit comments