also looking at this
fix(migrate)!: run the directories executeMigration was given
#1138
7 files
+348
-49
| @@ -97,7 +97,7 @@ describe('an attribute added after the table was migrated', () => { | ||
| 97 | 97 | useOriginalDatabase() |
| 98 | 98 | writeModel(`name: { validation: { rule: {} } }`) |
| 99 | 99 | await generateMigration(modelsDir, { dialect: 'sqlite' }) |
| 100 | await executeMigration(modelsDir) | |
| 100 | await executeMigration() | |
| 101 | 101 | }) |
| 102 | 102 | |
| 103 | 103 | it('writes a migration for the change', async () => { |
| @@ -111,7 +111,7 @@ describe('an attribute added after the table was migrated', () => { | ||
| 111 | 111 | }) |
| 112 | 112 | |
| 113 | 113 | it('applies it to the database it was generated on', async () => { |
| 114 | await executeMigration(modelsDir) | |
| 114 | await executeMigration() | |
| 115 | 115 | expect(columnsOf(dbFile, 'widgets')).toContain('colour') |
| 116 | 116 | }) |
| 117 | 117 | |
| @@ -126,7 +126,7 @@ describe('an attribute added after the table was migrated', () => { | ||
| 126 | 126 | // The point of the whole corpus: a teammate clones, migrates, and gets the |
| 127 | 127 | // same table. If the ALTER is not in the files, they get yesterday's table. |
| 128 | 128 | const fresh = useFreshDatabase() |
| 129 | await executeMigration(modelsDir) | |
| 129 | await executeMigration() | |
| 130 | 130 | useOriginalDatabase() |
| 131 | 131 | |
| 132 | 132 | expect(columnsOf(fresh, 'widgets')).toContain('name') |
| @@ -135,7 +135,7 @@ describe('an attribute added after the table was migrated', () => { | ||
| 135 | 135 | |
| 136 | 136 | it('does not re-run on the machine that already applied it', async () => { |
| 137 | 137 | const before = migrationFiles() |
| 138 | await executeMigration(modelsDir) | |
| 138 | await executeMigration() | |
| 139 | 139 | |
| 140 | 140 | // Recorded, so it is not replayed — replaying an ADD COLUMN is the |
| 141 | 141 | // `duplicate column name` failure that takes the whole run down. |
| @@ -157,16 +157,16 @@ describe('a series of changes, each landing its own migration', () => { | ||
| 157 | 157 | |
| 158 | 158 | writeModel(`name: { validation: { rule: {} } }, colour: { validation: { rule: {} } }, size: { validation: { rule: {} } }`) |
| 159 | 159 | await generateMigration(modelsDir, { dialect: 'sqlite' }) |
| 160 | await executeMigration(modelsDir) | |
| 160 | await executeMigration() | |
| 161 | 161 | |
| 162 | 162 | writeModel(`name: { validation: { rule: {} } }, colour: { validation: { rule: {} } }, size: { validation: { rule: {} } }, weight: { validation: { rule: {} } }`) |
| 163 | 163 | await generateMigration(modelsDir, { dialect: 'sqlite' }) |
| 164 | await executeMigration(modelsDir) | |
| 164 | await executeMigration() | |
| 165 | 165 | |
| 166 | 166 | expect(migrationFiles().length).toBe(start + 2) |
| 167 | 167 | |
| 168 | 168 | const fresh = useFreshDatabase() |
| 169 | await executeMigration(modelsDir) | |
| 169 | await executeMigration() | |
| 170 | 170 | useOriginalDatabase() |
| 171 | 171 | |
| 172 | 172 | const columns = columnsOf(fresh, 'widgets') |
| @@ -196,12 +196,12 @@ describe('two changes migrated inside the same second', () => { | ||
| 196 | 196 | }) |
| 197 | 197 | |
| 198 | 198 | it('runs both, on this machine and on a fresh one', async () => { |
| 199 | await executeMigration(modelsDir) | |
| 199 | await executeMigration() | |
| 200 | 200 | expect(columnsOf(dbFile, 'widgets')).toContain('finish') |
| 201 | 201 | expect(columnsOf(dbFile, 'widgets')).toContain('grade') |
| 202 | 202 | |
| 203 | 203 | const fresh = useFreshDatabase() |
| 204 | await executeMigration(modelsDir) | |
| 204 | await executeMigration() | |
| 205 | 205 | useOriginalDatabase() |
| 206 | 206 | |
| 207 | 207 | const columns = columnsOf(fresh, 'widgets') |
| @@ -230,7 +230,7 @@ describe('a migration applied but never recorded', () => { | ||
| 230 | 230 | writeFileSync(orphan, `-- qb:generated\nALTER TABLE widgets ADD COLUMN colour TEXT;\n`) |
| 231 | 231 | |
| 232 | 232 | // `colour` is already on the table, so this SQL cannot succeed. |
| 233 | await executeMigration(modelsDir) | |
| 233 | await executeMigration() | |
| 234 | 234 | |
| 235 | 235 | expect(existsSync(orphan)).toBe(true) |
| 236 | 236 | expect(columnsOf(dbFile, 'widgets')).toContain('colour') |
| @@ -244,7 +244,7 @@ describe('a migration applied but never recorded', () => { | ||
| 244 | 244 | // recorded away. Only an unambiguous "already exists" is forgiven, and |
| 245 | 245 | // only for a migration the generator wrote. |
| 246 | 246 | let threw = false |
| 247 | try { await executeMigration(modelsDir) } | |
| 247 | try { await executeMigration() } | |
| 248 | 248 | catch { threw = true } |
| 249 | 249 | finally { rmSync(broken, { force: true }) } |
| 250 | 250 | |
| @@ -267,11 +267,11 @@ describe('the snapshot going missing does not duplicate work', () => { | ||
| 267 | 267 | }) |
| 268 | 268 | |
| 269 | 269 | it('leaves the database untouched and still replayable afterwards', async () => { |
| 270 | await executeMigration(modelsDir) | |
| 270 | await executeMigration() | |
| 271 | 271 | expect(columnsOf(dbFile, 'widgets')).toContain('weight') |
| 272 | 272 | |
| 273 | 273 | const fresh = useFreshDatabase() |
| 274 | await executeMigration(modelsDir) | |
| 274 | await executeMigration() | |
| 275 | 275 | useOriginalDatabase() |
| 276 | 276 | expect(columnsOf(fresh, 'widgets')).toContain('weight') |
| 277 | 277 | }) |