#database-migrations #postgresql #tool #migration #cli-tool #fly

app fly-migrate

A simple CLI database migration tool for postgresql

5 releases

0.2.1 Mar 23, 2024
0.2.0 Mar 23, 2024
0.1.2 Mar 11, 2024
0.1.1 Mar 30, 2023
0.1.0 Mar 29, 2023

#233 in Database interfaces

Download history 11/week @ 2024-02-18 14/week @ 2024-02-25 1/week @ 2024-03-03 146/week @ 2024-03-10 155/week @ 2024-03-17 40/week @ 2024-03-24 51/week @ 2024-03-31

392 downloads per month

MIT license

41KB
835 lines

fly

A simple CLI database migration tool for postgresql. Very much work-in-progress at the moment.

Installing

Available on crates.io as fly-migrate:

$ cargo install fly-migrate
# installs `fly` to `~/.cargo/bin`:
$ fly --help

Configuration

Fly expects the following env variables set. It will also use dotenv to look in a .env file.

  • MIGRATE_DIR: Path to your migrations (e.g., db/migrate).
  • PG_USER
  • PG_PASSWORD (optional)
  • PG_HOST
  • PG_PORT
  • PG_DB

You can use the example-env subcommand to output an example .env file to get started:

fly example-env >> .env

You can also directly set a PG_CONNECTION_STRING instead of the individual PG_ variables.

Subcommands

  • up: Applies all pending migrations.
  • down: Rolls back the last migration.
  • status: Prints the current status of the database.
  • new: Creates a new migration file.
  • example-env: Outputs an example .env file.

Development

Testing

Testing fly requires a postgres connection. You should set the following env variables:

TEST_PG_HOST=host
TEST_PG_PORT=port
TEST_PG_USER=user

You can put these in a .env.test in the root directory.

Dependencies

~14–26MB
~420K SLoC