An env-aware, forward-only, postgres migrator for solo devs and tiny teams.
- 💻 A simple CLI tool
- ⚡ recognizes
.env
files and environment variables for easy substitution into sql migration files - ⬆️ no messing around with down migrations: roll with the punches and roll forward.
(todo)
Supply these environment variables
# database connection string
PG_URL
# path to the folder that holds your migration files
MIGPATH
Then run the following command to initialise the migrator
nnmg init
To create a brand new migration, simply use nnmg create
followed by a description of the schema change. e.g.:
nnmg create add foo column to things table
☝️ This will create a new file in your migrations folder, named nnnn-add-foo-column-to-things.sql
, or similar. It will be empty, because nano-migrate doesn't opine on how you write your migrations and it doesn't support down migrations anyway, so really... enter whatever sql you'd like to run! :-)
To run all pending migrations that have not yet been applied to your database:
nnmg migrate
That's it!
Here's our tiny contributing guide. We especially welcome contributors who are learning go as well as people who want the experience of contributing to a project! :-)