sastraxi/pgsh

Migration backends

Closed this issue · 1 comments

Right now, we only support knex for migrations. However, there are many different migration tools out there for different stacks:

We can support these by adding a bit of logic around swapping out subcommands based on a new configuration parameter in .pgshrc: migrations.backend.

  • by default, this config value will be unset
  • we'll move the src/cmd/knex directory to src/cmd/migrate/knex
  • we'll use the subcommand implementation in the subdirectory that corresponds to the configured backend
  • each backend will implement the up, down, force-up, force-down, and validate subcommands
  • each backend will implement a detect function that returns a truthy value iff evidence that this migration tool is used in the current project directory
  • if a migration subcommand is run and no backend is set:
    • each detect command will be run, and the first backend to detect itself becomes the configured backend (with a corresponding message to the user and write to .pgshrc, if one exists)
    • if no backends are detected, the command will exit with an error

Initial implementation sketch in #47