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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nestjs-neo4j-migrations

v0.0.6

Published

Neo4j migration management for NestJs applications

Downloads

30

Readme

Neo4j migrations manager for NestJs

This package is inspired by TypeORM style of migration management. It tracks migrations directly inside neo4j database and runs them in order.

Disclaimers

  • WIP, lacks tests and not ready for production use
  • Beware that Neo4j migrations cannot have both schema and data changes in the same migration!
  • CLI for reverting is lacking but functional
  • No generation of migrations yet

Shoutouts

Installation

npm i nestjs-neo4j-migrations

Usage

In static modules

import { Global, Module } from '@nestjs/common';
import { Neo4jDriverModule } from 'nestjs-neo4j-migrations';

import { migrations } from './migrations';

@Global()
@Module({
  imports: [
    Neo4jDriverModule.forRoot({
      uri: process.env.NEO4J_URI,
      username: process.env.NEO4J_USERNAME,
      password: process.env.NEO4J_PASSWORD,
      migrations,
    }),
  ],
})
export class Neo4jModule {}

In dynamic modules

import { Global, Module } from '@nestjs/common';
import { Neo4jDriverModule } from 'nestjs-neo4j-migrations';

import { Config } from './config';

import { migrations } from './migrations';

@Module({
  imports: [
    Neo4jDriverModule.forRootAsync({
      inject: [Config],
      useFactory: (config: Config) => ({
        uri: config.neo4jUri,
        username: config.neo4jUser,
        password: config.neo4jPassword,
        migrations,
      }),
    }),
  ],
})
export class Neo4jModule {}

Migrations file

This acts as datasource options file, it should export an array of migrations (see example of one below), uri, username and password.

// migrations/index.ts

import dotenv from 'dotenv';
import { Neo4jMigrationList } from 'nestjs-neo4j-migrations';

import { InitMigration1234 } from './1234-Init';

dotenv.config();

export const migrations: Neo4jMigrationList = [
  InitMigration1234,
  // ... append more migrations here
];

export const uri = process.env.NEO4J_URI;
export const username = process.env.NEO4J_USERNAME;
export const password = process.env.NEO4J_PASSWORD;

Migration example

Note that key can be any sequential number, but it is recommended to use timestamp for it. Make sure your up() and down() methods are idempotent. Use IF NOT EXISTS and IF EXISTS to avoid errors when running migrations multiple times.

Note: session is exposed to allow multi-transactional migrations on large datasets, when memory is a concern. In most cases you'll want to use single transaction. Learn more here https://neo4j.com/docs/javascript-manual/current/transactions/

import { Neo4jMigration, Neo4jSession } from 'nestjs-neo4j-migrations';

export class AddIndex1723704012000 implements Neo4jMigration {
  readonly key = 1723704012000;

  async up(session: Neo4jSession): Promise<void> {
    await session.executeWrite((trx) =>
      trx.run(`CREATE INDEX ageId IF NOT EXISTS FOR (e:employees) ON (e.age)`),
    );

    // Beware that if you change schema (indexes, constraints, etc) you cannot have data changes in the same migration, you'll have to split them.
  }

  async down(session: Neo4jSession): Promise<void> {
    const trx = session.beginTransaction();
    await trx.run(`DROP INDEX ageId IF EXISTS`);
    await trx.commit();
  }
}

Reverting

npx nestjs-neo4j-migrations revert -c ./migrations

In this example migrations directory contains index.ts file described above.