Commit 5865ad5
Make
Previously, `db:migrate:status:with_data` used `Dir.foreach` and
`Dir.children`, which only scan the top-level migration directory. As a
result, archived migrations placed in subdirectories (e.g.,
`db/migrate/archive/`) appeared as "*** NO SCHEMA FILE ***" even though
they existed in the database.
The fix switches to `Dir.glob` with a recursive `**/*.rb` pattern and
then filters by matching file basenames against `/(\d{14})_(.+)\\.rb/`,
enabling the command to find migrations in nested directories and
correctly report their status.
This ensures that migrations stored anywhere under the migration paths
are recognized and displayed accurately in the status output.
Before:
```
~/Project (main) % bundle exec rake db:migrate:status | grep 20210323133030
up 20210323133030 Create resource
~/Project (main) % bundle exec rake db:migrate:status:with_data | grep 20210323133030
up 20210323133030 *** NO SCHEMA FILE ***```
```
After:
```
~/Project (main) % bundle exec rake db:migrate:status | grep 20210323133030
up 20210323133030 Create resource
~/Project (main|!|+) % bundle exec rake db:migrate:status:with_data | grep 20210323133030
up schema 20210323133030 Create resource
```status command find migrations in subdirectories1 parent a59d19a commit 5865ad5
File tree
2 files changed
+56
-9
lines changed- lib/data_migrate/tasks
- spec/data_migrate/tasks
2 files changed
+56
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 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 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
128 | 173 | | |
129 | 174 | | |
0 commit comments