Commit e45b496
authored
fix: use backwards_plan to build exact rollback plan in downgrade() (#50)
* fix: use backwards_plan to build exact rollback plan in downgrade()
The previous implementation targeted same_app_parents[0] as the migration
target, which caused Django's executor to find all same-app children of
that parent and roll them all back. In a merge-migration graph:
0001 -> 0002a -> 0003_merge
-> 0002b /
Calling downgrade('myapp', '0002b') would target 0001, causing Django to
roll back 0003_merge + 0002a + 0002b — leaving only 0001 applied. 0002a
should have been left untouched.
Fix: use graph.backwards_plan(key) to compute the exact set of migrations
to unapply (the target + anything that depends on it), then pass the result
directly to executor.migrate([], plan=...). This rolls back only what is
necessary and leaves sibling branches intact.
Fixes #45
* ci: skip unchanged jobs using dorny/paths-filter
Add a changes job that detects which paths were modified. Each job now
only runs when relevant files change:
- lint, test (unit): pytest_mrt/** or pyproject.toml
- test-django: above + pytest_mrt/adapters/django*.py or tests/test_django*.py
- test-postgres/mysql/oracle/mssql: above + their respective test files
- ci.yml changes trigger all jobs
Docs-only and README changes no longer trigger any CI jobs.
* style: ruff format django_runner.py1 parent 9df7aff commit e45b496
3 files changed
Lines changed: 147 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
10 | 43 | | |
| 44 | + | |
| 45 | + | |
11 | 46 | | |
12 | 47 | | |
13 | 48 | | |
| |||
29 | 64 | | |
30 | 65 | | |
31 | 66 | | |
| 67 | + | |
| 68 | + | |
32 | 69 | | |
33 | 70 | | |
34 | 71 | | |
| |||
61 | 98 | | |
62 | 99 | | |
63 | 100 | | |
| 101 | + | |
| 102 | + | |
64 | 103 | | |
65 | 104 | | |
66 | 105 | | |
| |||
94 | 133 | | |
95 | 134 | | |
96 | 135 | | |
| 136 | + | |
| 137 | + | |
97 | 138 | | |
98 | 139 | | |
99 | 140 | | |
| |||
128 | 169 | | |
129 | 170 | | |
130 | 171 | | |
| 172 | + | |
| 173 | + | |
131 | 174 | | |
132 | 175 | | |
133 | 176 | | |
| |||
148 | 191 | | |
149 | 192 | | |
150 | 193 | | |
| 194 | + | |
| 195 | + | |
151 | 196 | | |
152 | 197 | | |
153 | 198 | | |
| |||
181 | 226 | | |
182 | 227 | | |
183 | 228 | | |
| 229 | + | |
| 230 | + | |
184 | 231 | | |
185 | 232 | | |
186 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
166 | | - | |
167 | | - | |
168 | | - | |
| 172 | + | |
169 | 173 | | |
170 | 174 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
177 | 180 | | |
178 | | - | |
| 181 | + | |
| 182 | + | |
179 | 183 | | |
180 | 184 | | |
181 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
232 | 241 | | |
233 | | - | |
234 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
235 | 246 | | |
236 | | - | |
237 | | - | |
| 247 | + | |
| 248 | + | |
238 | 249 | | |
239 | 250 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
244 | 259 | | |
245 | | - | |
246 | | - | |
| 260 | + | |
247 | 261 | | |
248 | | - | |
249 | | - | |
| 262 | + | |
250 | 263 | | |
251 | 264 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 265 | + | |
| 266 | + | |
256 | 267 | | |
257 | | - | |
258 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
259 | 322 | | |
260 | 323 | | |
261 | 324 | | |
| |||
0 commit comments