Skip to content

Commit

Permalink
fix: migrate down missing filter for latest batch (#4860)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRibbens committed Jan 17, 2024
1 parent 836ed77 commit b99d24f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/payload/src/database/migrations/migrateDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export async function migrateDown(this: BaseDatabaseAdapter): 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 b99d24f

Please sign in to comment.