How to apply migrations from cypher files or from OGM

Hi, I am trying to use memgraph for my upcoming project but I can’t find any information in the documentation or forums which describe the process of applying migrations to the database. There are some projects like GitHub - michael-simons/neo4j-migrations: Automated script runner aka "Migrations" for N which work for standard neo4j but due to the change which disallows unique constraints from being created in multi line transactions, it is not currently suitable for a memgraph application.

Is there a recommended way to apply these migrations such that certain constraints can be created and run from an application?

Hi, you linked to a really interesting project.
It’s true, because they are using session.writeTransaction you cannot create Unique constraints in both transaction modes.
Does that mean you have a single cypher file you would like to load in Memgraph?
If that’s the case, you can try with mgconsole and use piping:
mgconsole < your_file.cypher which will run all the commands line by line.
If you have Linux, you can find the source of mgconsole here.

Hey krowan, I don’t think we currently support OGM migrations in any of our tools currently, but this is something that will definitely end up on the roadmap at some point. Probably in the GQLAlchemy first.

What language are you using in your project? Maybe there’s a way to support a third-party tool, but there might be differences in which Memgraph and Neo4j implement Cypher so it might still prove to be difficult. Also, what would be the main features you’d be interested in seeing us supporting?

That makes sense. I will probably go with a similar approach to this just to make things simple. Thank you.

Ok that is understandable. My project is using java but after consideration I believe it would be best to keep things relatively simple by having a source of truth for all constraints in the database which will be run by a central system to provide the schema rather than having a more complex migration system. I look forward to your implementations in GQLAlchemy though. Thank you for the response.

I’ll pass your feedback to the product team. Good luck with the project and let us know if you run into any issues, we’re happy to help! :smile: