@vdtn359/faunadb-migrate
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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\#master

Before start

Before start you should set FAUNADB_SECRET env variable with a faunadb admin key.

export FAUNADB_SECRET=fnyoursecret-here

Commands

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 setup

Create migrations

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.

Migrate

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

Rollback all the previous changes.

faunadb-migrate rollback

Help

See all available commands and params.

faunadb-migrate --help

Improvements

  • Tests, tests and tests
  • Add --force option to ignore errors
  • Better error handling

Dependents (0)

Package Sidebar

Install

npm i @vdtn359/faunadb-migrate

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

35.7 kB

Total Files

29

Last publish

Collaborators

  • vdtn359