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

neo4j-migrate

v0.2.0

Published

A tool for running immutable migrations on a Neo4J database

Downloads

11

Readme

neo4j-migrate

A tool for running immutable migrations on a Neo4J database

Usage

NOTE: this project is in active development. All usage below is still speculative and in progress. No guarantees are made that usage will stay consistent in the near future, although semver will be used to indicate breaking changes.

Environment Variables

Certain environment variables can be defined to supply common parameters:

NEO4J_HOST=bolt://your-neo4j-host:7687
NEO4J_USERNAME=neo4j|your_username
NEO4J_PASSWORD=your_password

All of these parameters can also be supplied via the CLI or module usage, and will override environment parameters if you do so.

Version bookmarking

By default, this tool will store a version bookmark in a node inside your graph with a :Neo4jMigrateStorage label. This bookmark is used to avoid re-applying migrations upon future up or down commands. While the default migrations should all be basically idempotent, custom Cypher migrations may not be, plus it's just faster.

If you want to disable this behavior, pass the --force flag. If you'd like to store the version bookmark in a different place, feel free to open a PR.

CLI

Create a migration file

$ npx neo4j-migrate create-migration --name=example-migration ./migrations

Creates a file like this:

000-example-migration.yaml

---
# simple property index
- kind: index
  type: node_label_property
  operation: create # operation is optional, defaults to create
  label: Person
  properties:
    - id
  # compound property index
- kind: index
  type: node_label_property
  label: Person
  properties:
    - name
    - bio
  # fulltext index (Neo4j 3.5+)
- kind: index
  type: node_fulltext
  name: testindex
  labels:
    - Post
  properties:
    - title
    - text
  # removing a property index
- kind: index
  type: node_label_property
  operation: delete # specify delete as operation
  label: Person
  properties:
    - email
  # removing a fulltext index (name only required)
- kind: index
  type: node_fulltext
  operation: delete
  name: oldindex
# unique property constraint
- kind: constraint
  type: node_unique_property
  label: Person
  property: id
# example of arbitrary cypher migration, which may or may not be reversible
- kind: cypher
  up: 'MATCH (p:Person) SET p.name = trim(p.name)'
  down: null

Migrate up

$ npx neo4j-migrate up --url bolt://localhost:7687

Migrates the database up, running each migration file in order. See -h for more options.

Migrate down

$ npx neo4j-migrate down --url bolt://localhost:7687

Migrates the database down, UNDOING each migration file in REVERSE order. See -h for more options.

Note that Cypher change sets must supply a down parameter to be reversed. Otherwise, they will be skipped.

Module

Migrate up

import * as path from 'path';
import { up } from 'neo4j-migrate';

await up({
  // all parameters optional
  migrationDir: path.resolve(process.cwd(), 'migrations'),
  target: 3,
  url: 'bolt://localhost:7687',
  username: 'neo4j',
  password: 'secret',
  neo4jConfig: {
    logging: {
      level: 'debug',
    },
  },
  force: true,
});

Migrate down

import * as path from 'path';
import { down } from 'neo4j-migrate';

await down({
  // all parameters optional
  migrationDir: path.resolve(process.cwd(), 'migrations'),
  target: 3,
  url: 'bolt://localhost:7687',
  username: 'neo4j',
  password: 'secret',
  neo4jConfig: {
    logging: {
      level: 'debug',
    },
  },
  force: true,
});