@vdtn359/faunadb-migrate v1.0.0
faunadb-migrate
FaunaDB Migrate is a tool to help faunadb developers setup theirs app database. This is not an official tool supported by Fauna
Install
npm i -g git+https://github.com/BrunoQuaresma/faunadb-migrate.git\#masterBefore start
Before start you should set FAUNADB_SECRET env variable with a faunadb admin key.
export FAUNADB_SECRET=fnyoursecret-hereCommands
Setup
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 setupCreate migrations
Create new migration file inside of ./migrations folder.
faunadb-migrate create create_usersThis 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.
Migrate
Run the migration files.
faunadb-migrate migrateCurrently 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
Rollback all the previous changes.
faunadb-migrate rollbackHelp
See all available commands and params.
faunadb-migrate --helpImprovements
- Tests, tests and tests
- Add
--forceoption to ignore errors - Better error handling
6 years ago