arangomigration

ArangoDB migration cli tool

Usage no npm install needed!

<script type="module">
  import arangomigration from 'https://cdn.skypack.dev/arangomigration';
</script>

README

Arango Migration Tool

This tool will help you to manage your ArangoDB with migration file to easily create users, document, indexes & views from a simple folder with yaml files.

It can also insert default data from the same folder.

Getting started

1. Installation

# install localy, so you can use it with npx in your folder
npm install arangomigration

# or install globaly to get access to the cli from anywhere
npm install -g arangomigration

2. Add some migration files

  1. Create a migration folder at your project root
  2. Add yaml files in semvers format with a name: x.x.x-add-a-collection.yml

Your folder should look like this:

./migration
├── 1.0.0-mvp-needs.yml
└── 1.0.1-add-missing-index.yml

3. Write a migration file

database: my-database

create:
  users:
    - username: user1
      password: usernamepassword
  collection:
    - name: dogs
    - name: dogSitter
  edgeCollection:
    - name: dogSitterDogs
  indexes:
    - name: oneDogSitterForADog
      collection: dogSitterDogs
      type: persistent
      unique: true
      fields:
        - _from
        - _to

This migration file will do:

  1. Create my-database database if not exist
  2. Create user1 user in _system database
  3. Create a collection and an edge collection
  4. Create a persistent index on the edgeCollection dogSitterDogs to ensure that a dog has only a dog sitter

Run migration

This tool is a cli, so you can basicly use this command line

(npx) arangomigration migrate

Main commands

$ arangomigration arangomigration --help

Usage: arangomigration [options] [command]

Options:
  -v, --version                 output the version number
  -h, --help                    display help for command

Commands:
  apply [options] [directory]   Apply all migration files from a directory
  status [options] [directory]  Check local file and compare to previously applied migration
  help [command]                display help for command

Apply command

$ arangomigration apply --help

Usage: arangomigration apply [options] [directory]

Apply all migration files from a directory

Options:
  --url <url>              URL of your database (default: "http://localhost:8529")
  --username <username>    System username (default: "root")
  --password <password>    System user password (default: "root")
  --insert-data <boolean>  Insert data from ~/your-migration-folder/data (default: true)
  -h, --help               display help for command

Status command

$ arangomigration status --help

Usage: arangomigration status [options] [directory]

Check local file and compare to previously applied migration

Options:
  --url <url>            URL of your database (default: "http://localhost:8529")
  --username <username>  System username (default: "root")
  --password <password>  System user password (default: "root")
  -h, --help             display help for command