Skip to content

Cannot run skipped migration without rolling back #164

@reffu42

Description

@reffu42

Describe the bug
It doesn't seem like there's a way to force postgrator to run a script that has been skipped/missed without first rolling back (assuming you have an undo for every script in between) and then re-running.

To Reproduce

  1. Create a handful of scripts that make small changes to the database.
  2. Number them sequentially
  3. Skip a number and create one more (e.g. 001, 002, 003, 005)
  4. Run Postgrator
  5. Create a script for the skipped number (004)
  6. Run Postgrator again
  7. Note that because the script is less than the current "version" it does not run or get added to the schema_versions table

Expected behavior
Since the script has not yet been run and is not in the schema_versions table, it should be run (or at least make a command/option to "catch up" and run any missed scripts/numbers)

Additional context
This is useful in cases where you have a shared repository and multiple developers. It is also necessary if you have a "dev" and "prod" setup and need to commit a quick fix to the "prod" version while working on the "dev" version (e.g. script 039 is run in dev as part of a feature, but a bug in prod requires script 040 to fix it first. When 039 is pulled to prod, it will not run)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions