Skip to content

Commit

Permalink
fix(db-postgres): migrate down only runs latest batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRibbens committed Jan 9, 2024
1 parent 555d027 commit 6acfae8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/db-postgres/src/migrateDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export async function migrateDown(this: PostgresAdapter): Promise<void> {
msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,
})

for (const migration of existingMigrations) {
const latestBatchMigrations = existingMigrations.filter(({ batch }) => batch === latestBatch)

for (const migration of latestBatchMigrations) {
const migrationFile = migrationFiles.find((m) => m.name === migration.name)
if (!migrationFile) {
throw new Error(`Migration ${migration.name} not found locally.`)
Expand Down

0 comments on commit 6acfae8

Please sign in to comment.