This project is for experimenting with neo4j graph database.
Under resources/data-creation there are .http
scripts that you can run, after launching the application and its docker-compose, file that will populate the db with data.
You have to make sure as well to select an environment for the scripts to read some variables.
The persistence layer is implemented using various ways:
- Neo4jRepo
- Neo4jTemplate
- Neo4jClient
To pick one of them, you have to set the value of the myapp.persistence.strategy
property in the application.properties
file.
In the usecase implemented here I only need to create some contraints and indexes on the database but this topic is of course valid for schema changes to the graph.
You can create a hook on application startup and run the cypher queries to apply the migrations. You have to handle though the history of the migrations and validations yourself.
Liquibase is open source project that helps you track, version, and deploy database schema changes. It is most famous for RDBMS projects.
Neo4j team created a extension/plugin for Liquibase as successor for the deprecated Liquigraph tool. This extension is under the Neo4j Labs projects 1.
Liquibase in general has a Spring boot integration but with Neo4j (with the plugin) it seems difficult to make it run the same way it does with RDBMSs on application startup. You can still run the migrations manually using the liquibase command line tool or the gradle plugin.
- Neo4j plugin for Liquibase
- Liquibase-neo4j tutorial
- Liquibase-neo4j another tutorial
- Deprecation of Liquigraph
This tool is also a project under the neo4j labs1 started in 2021. The reason for its creation is that the Neo4j team needed a tool that is
- More compatible with spring data neo4j and other frameworks (e.g, quarkus)
- Contains as little dependencies as possible
- As little overhead as possible on the concepts of neo4j
And as per Michael Simons staff engineer at Neo4j, Liquigraph/Liquibase-Neo4j felt too alien for Neo4j.
As of 2024 it is still under the current projects in the labs. It is a tool that is used to manage schema migrations in a Neo4j database. It is inspired by FlywayDB. It is built on top of the official Neo4j-Java-Driver and has Spring boot integration. Here is a excerpt from the official documentation:
"Neo4j-Migrations is a set of tools to make your schema migrations as easy as possible. It provides a uniform way for applications, the command line and build tools alike to track, manage and apply changes to your database. It is inspired to a large extent by FlywayDB, so most things evolve around Cypher-Scripts. Neo4j-Migrations builds directly on top of the official Neo4j-Java-Driver, supports Neo4j 3.5, Neo4j 4.1 to 4.4 and Neo4j 5, including enterprise features such as multidatabase support and impersonation.
All provided modules have feature parity: Commands in the API reflect in the CLI, in the Maven as well as in the Spring Boot integration"
Neo4j-Migrations manages the history of applied migrations as a subgraph stored in your database.
It is important to note that it is mentioned in the docs that Neo4j-Migrations is only tested again Neo4j and Neo4j-Aura. Here is the corresponding excerpt from the official documentation:
"Neo4j-Migrations is tested only against Neo4j, the world’s leading Graph database. Neo4j-Migrations requires a 4.x version of Neo4j Java Driver. The project is build and tested with the latest 4.4 version, however previous versions 4.3, 4.2 and 4.1 are supported as well and can be used as drop-in-replacement. Therefore, Neo4j-Migrations works with Neo4j 3.5, 4.0 - 4.4 and of course, Neo4j-Aura. It also can be used with an embedded instance, as long as the embedded instances provides the Bolt-Connector, too. The tooling may or may not work with other databases using the Bolt protocol. We don’t provide any support for those."
- Neo4j-Migrations
- Michael Simons Staff Engineer @ Neo4j about Neo4j-Migrations
- Adding Constraints using Neo4j-Migrations
1: As mentioned in the Neo4j Labs docs, all projects done under it form a collection of the latest innovations in graph technology. Although they are designed and tested by the Neo4j team,as extensions to their product offerings, that does not guarantee that the project will "graduate" to a fully supported product. Neo4j Labs Docs