rerun SKIP does not work when using to and sequelize storage

Open
#588 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
aws, typescript
Domain
backend, databases

Research direction

No files or tests are named. Start by reproducing the migration flow with SequelizeStorage, SQL migrations, to, and rerun: 'SKIP'; then trace how pending migrations are selected for the to path. Done means previously executed migrations are skipped rather than causing a "Couldn't find migration" error.

Written by the indexing model from the issue text.

Description

Version: 3.2.1
Storage: SequelizeStorage
Dev setup: Typescript

Reproduction:

  1. Run migrations using .sql files first
  2. Rerun using 'to' to run to a specific migration, with rerun set to SKIP

Expected:
In this case it is expected that it would skip any migrations that have already been run.

Actual:
Migration fails with 'Couldn't find migration' Error because pending migrations will not include migrations found in SequelizeStorage making the rerun flag redundant and the behavior a bit broken.

It appears that the rerun flag is only applicable when 'migrations' are passed to up, not when 'to' is used.

We use AWS CustomResources to control migrations in our environment and that means we create the CustomResource with an up and down migration set and this causes them to fail if we for some reason need to rerun the underlying AWS Lambda with the same parameters. To solve this we need to be able to skip any migration that has already been run, instead of having it throw this error. Not sure about the approach here as rerun and to in this context seems to more mean that it would then only be that migration that would be skipped if it was already ran.

I guess a workaround would be to simple load the glob we use, sort it, and then slice at the 'to' index and run those migrations with rerun: 'SKIP'.

Dominant language
TypeScript
Stars
2.2k
Forks
163
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sequelize/umzug

All issues in sequelize/umzug

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.