Registry / database / nestjs-neo4j-migrations

nestjs-neo4j-migrations

JSON →
library0.0.6jsnpmunverified

Neo4j migration management for NestJS applications, inspired by TypeORM. Current version 0.0.6 (WIP, not production-ready). Provides a declarative way to apply and revert schema and data migrations inside Neo4j directly, tracking them in the database. Key differentiators: integrates with NestJS module system, supports both static and async module configuration, and retains session access for multi-transactional migrations. Limitations: no migration generation, CLI revert lacks features, no tests, and disallows mixing schema and data changes in one migration.

npm install nestjs-neo4j-migrations
INSTALL
IMPORT
SIG · NESTJS-NEO4J-MIGRA
N
nestjs-neo4j-migrations
databasejavascriptv0.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Neo4jDriverModule
import { Neo4jDriverModule } from 'nestjs-neo4j-migrations'
import { Neo4jDriverModule } from 'nestjs-neo4j-migrations/Neo4jDriverModule'
Main module class for configuring the migration module.
Neo4jMigration
import { Neo4jMigration } from 'nestjs-neo4j-migrations'
import { Neo4jMigration } from 'nestjs-neo4j-migrations/types'
Interface for defining a migration class with key, up(), down().
Neo4jMigrationList
import { Neo4jMigrationList } from 'nestjs-neo4j-migrations'
type Neo4jMigrationList = import('nestjs-neo4j-migrations').Neo4jMigrationList
Type alias for an array of Neo4jMigration class constructors.
Neo4jSession
import { Neo4jSession } from 'nestjs-neo4j-migrations'
import { Neo4jSession } from 'neo4j-driver'
Re-exported type from neo4j-driver; used in migration up/down methods.

Shows how to define migrations and configure the Neo4jDriverModule with static forRoot() method.

// migrations/index.ts import { Neo4jMigrationList, Neo4jDriverModule } from 'nestjs-neo4j-migrations'; import { InitMigration } from './1234-Init'; export const migrations: Neo4jMigrationList = [InitMigration]; // app.module.ts import { Module } from '@nestjs/common'; import { Neo4jDriverModule } from 'nestjs-neo4j-migrations'; import { migrations } from './migrations'; @Module({ imports: [ Neo4jDriverModule.forRoot({ uri: process.env.NEO4J_URI ?? 'bolt://localhost:7687', username: process.env.NEO4J_USERNAME ?? 'neo4j', password: process.env.NEO4J_PASSWORD ?? 'password', migrations, }), ], }) export class AppModule {} // migrations/1234-Init.ts import { Neo4jMigration, Neo4jSession } from 'nestjs-neo4j-migrations'; export class InitMigration1723704012000 implements Neo4jMigration { readonly key = 1723704012000; async up(session: Neo4jSession): Promise<void> { await session.executeWrite((trx) => trx.run('CREATE CONSTRAINT unique_email IF NOT EXISTS FOR (u:User) REQUIRE u.email IS UNIQUE') ); } async down(session: Neo4jSession): Promise<void> { await session.executeWrite((trx) => trx.run('DROP CONSTRAINT unique_email IF EXISTS') ); } }
Debug
Known issues
gotchaWIP - not ready for production use. Lacks tests and CLI features.
fix
Use with caution; do not rely on this package in production environments.
affects: <=0.0.6
gotchaCannot mix schema changes and data changes in a single migration. Doing so may cause inconsistent state.
fix
Split schema and data changes into separate migration files.
affects: >=0.0.1
deprecatedNo official deprecation; but version is low and may break in future releases without notice.
fix
Pin exact version and test upgrades.
affects: >=0.0.1
gotchaCLI revert command exits with no error if migration directory path is wrong or missing index.ts.
fix
Ensure the path argument (-c) points to a directory containing an index.ts that exports migrations, uri, username, and password.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'nestjs-neo4j-migrations'
Missing installation of the package.
fix
Run 'npm install nestjs-neo4j-migrations'.
TypeError: Neo4jDriverModule.forRoot is not a function
Incorrect import or using a version that does not export forRoot.
fix
Ensure you import Neo4jDriverModule from 'nestjs-neo4j-migrations' and use the correct static method.
Error: connect ECONNREFUSED ::1:7687
Neo4j database not running or connection URI wrong.
fix
Start Neo4j or update the URI/port in the module configuration.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies
@nestjs/commonrequiredPeer dependency for NestJS module integration
neo4j-driverrequiredPeer dependency for Neo4j database driver
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
nestjs-neo4j-migrations — npm install nestjs-neo4j-migrations · libregistry