npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gremlin-migrate

v1.0.8

Published

Runs gremlin-groovy scripts in-order to upgrade the DB schema

Downloads

193

Readme

gremlin-migrate

Runs gremlin-groovy scripts in-order to upgrade the DB schema

This library can be used to run a sequence of groovy scripts, which are submitted to gremlin-javascript, to perform changes on the target database. Most likely these will be schema changes.

The files are ordered based on semver naming conventions.

Installation

npm install gremlin-migrate --save

Usage

The library exports a function taking configuration parameters and returning an ES6 promise.

import upgradeDbToLatest from 'gremlin-migrate';
...
upgradeDbToLatest(janusGraphDbAddress, portNumber, pathToUpgradeScriptDirectory).then(() => {
    console.log('SUCCESS!');
});

Script library

If you want to use common functions across your groovy files, you can put them in a 'common.groovy' file in the update script directory. These will be available in all of the upgrade files.

Example

0.0.1.groovy (in 'upgradeScripts' subdir)

// I am an example of a comment!
graph.addVertex(label, 'person').property('name', 'john').iterate();
person2 = graph.addVertex(label, 'person');
// NOTE: Don't forget to add the '.next()' else the step won't necessarily take effect!
person2.property('name', 'john').next();
// DON'T put transactions in your upgrade scripts. The scripts are automatically wrapped in a transaction.
// graph.tx().commit();

Example.ts

import { createClient } from 'gremlin';
import upgradeDbToLatest from 'gremlin-migrate';
const client = createClient(8182, '192.168.99.100');

export default class Example {
  public test() {
    client.execute('g.V().hasLabel(\'person\').has(\'name\', \'john\')', (err, results) => {
      console.log('BEFORE UPGRADE: ' + JSON.stringify(results)); // []
      upgradeDbToLatest('192.168.99.100', 8182, __dirname + '/upgradeScripts/').then(() => {
        client.execute('g.V().hasLabel(\'person\').has(\'name\', \'john\')', (err, results) => {
          console.log('AFTER UPGRADE: ' + JSON.stringify(results)); // [ {vertex with person 'john'} ]
        });
      });
    });
  }
}

Tests

The tests are run against a janus-graph/dynamoDb backend configuration to exercise the transaction locking. They spin up docker containers using docker-compose with an empty DB so you will need docker set up on your system.

Run 'docker-compose build' and wait until that finishes (this is a one-off step)

Run 'gulp build' to build the app.

Then run 'gulp test' to run the tests.

To Publish

  1. Build and test the app.
  2. Run 'gulp export' to prepare for the release
  3. Commit and push your changes up to github
  4. npm publish!

About

My specific use-case was for flyway-like migrations for janus-graph, but I couldn't find a tool that did that.

Contributions

Pull requests will be gratefully received. Please ensure you have a test around the change/improvement you are proposing.