-
Notifications
You must be signed in to change notification settings - Fork 1
Migrations
Nexi comes with a built in database migration tool that allow you to adjust and add to your database schema through code. Nexi's migrations are built on top of knex migrations, which are fully featured and well supported.
Nexi looks for migrations in a directory named migrations
in the root of your application. To create a new migration you can run nexi-migrate make my_migration_name
. This will generate an empty migration file that you can fill in to describe the changes to your database.
Check out knex's schema builder documentation for details of how to define your database changes.
To apply the database migration when you are all finished run nexi-migrate latest
. If you want to roll those changes back to make a change or disregard them, you can run nexi-migrate rollback
. For other migration cli options, see the migrate cli options. nexi-migrate
supports any knex migrate:*
option, all you have to do is replace "knex migrate:" "nexi-migrate ".
Nexi migration uses database credentials configured in the application config. To use an environment variable manager like dotenv, you can run nexi-migrate like node -r dotenv/config node_modules/.bin/nexi-migrate *