← 全部工具

morpheus4j

热度 65 更新于 开发与构建

Morpheus is a migration tool for Neo4j. It aims to be a simple and intuitive way to migrate your database.

npmauto-collected

安装

npm
npm install -g morpheus4j

通过 npm 安装。

Morpheus

<a href='https://coveralls.io/github/marianozunino/morpheus?branch=master' <img src='https://coveralls.io/repos/github/marianozunino/morpheus/badge.svg?branch=master&killcache=1' alt='Coverage Status' </a [](https://npmjs.org/package/morpheus4j) [](https://npmjs.org/package/morpheus4j) <a href="http://nestjs.com/" target="blank"<img src="https://nestjs.com/img/logo-small.svg" width="25" alt="Nest Logo" /</a

About

Morpheus is a modern, open-source database migration tool for Neo4j. It is designed to be a simple, intuitive tool for managing database migrations. The project is inspired by Michael Simons' tool for Java.

Quick Start

npm install -g morpheus4j
morpheus init         # Create config file
morpheus create user-nodes  # Creates V1_0_0__user-nodes.cypher
morpheus migrate     # Run migrations

Prerequisites

  • Node.js
  • Neo4j database (4.4.4 or 5.x)
  • npm or yarn package manager

Migration Files

Migration files:

  • Use .cypher extension
  • Are versioned using semver (e.g., V100createusers.cypher)
  • Contain pure Cypher queries
  • Each statement must end with a semicolon

Example migration file V100createusers.cypher:

CREATE CONSTRAINT user_email IF NOT EXISTS FOR (u:User) REQUIRE u.email IS UNIQUE;

CREATE (u:User {
  email: 'admin@example.com',
  name: 'Admin User',
  created_at: datetime()
});

File Naming Convention

Migration files follow this pattern:

  • Prefix: V (for version)
  • Version: Semver numbers separated by underscores (e.g., 100)
  • Separator: Double underscore
  • Description: Descriptive name using hyphens
  • Extension: .cypher

Example: V100create-user-constraints.cypher

Environment Variables