FaunaDB Migrate is a tool to help faunadb developers setup theirs app database. This is not an official tool supported by Fauna
npm i -g git+https://github.com/BrunoQuaresma/faunadb-migrate.git\#master
Before start you should set FAUNADB_SECRET
env variable with a faunadb admin key.
export FAUNADB_SECRET=fnyoursecret-here
Setup migrations in faunadb. You should use this command before run the migrations.
faunadb-migrate setup
# or using a scope env
FAUNADB_SECRET=fnyoursecret-here faunadb-migrate setup
Create new migration file inside of ./migrations
folder.
faunadb-migrate create create_users
This command will generate the following template for you:
module.exports.up = q => {
return q.CreateCollection({ name: 'Users' })
}
module.exports.down = q => {
return q.Delete(q.Collection('Users'))
}
The collection name is not dynamic. "Users" is only a sample.
Run the migration files.
faunadb-migrate migrate
Currently we are not handling failures well so in case of runnning mutiple migrations and something get wrong you should remove the "garbage" using the console UI or fauna-shell.
Rollback all the previous changes.
faunadb-migrate rollback
See all available commands and params.
faunadb-migrate --help
- Tests, tests and tests
- Add
--force
option to ignore errors - Better error handling