Registry /
database / nestjs-neo4j-migrations
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')
);
}
}
Errors
Common errors & fixes
Error: Cannot find module 'nestjs-neo4j-migrations'
Missing installation of the package.
fixRun 'npm install nestjs-neo4j-migrations'.
TypeError: Neo4jDriverModule.forRoot is not a function
Incorrect import or using a version that does not export forRoot.
fixEnsure 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.
fixStart Neo4j or update the URI/port in the module configuration.
Audit
Dependencies
@nestjs/commonrequiredPeer dependency for NestJS module integration
neo4j-driverrequiredPeer dependency for Neo4j database driver