Skip to content

Demonstrating our approach to performing migrations on our Memgraph DB. Extracted from Community Search's backend

License

Notifications You must be signed in to change notification settings

orbit-love/mg-migrations-showcase

Repository files navigation

Memgraph Migrations Showcase

Tasks

Tasks are defined under the tasks directory. You can create a task at any nesting level and run it with:

yarn task path:to:task --arg1=1 --arg2=2

For instance

yarn task examples:echo --foo=bar --baz=3

Should print out the arguments

To create your own task, simply follow the same pattern as ./tasks/examples/echo.js.

Migrations

Migrations are controlled by a set of 3 tasks

Generate

yarn task migrate:new --name my_new_migration

This task will create a new timestamped file under ./migrations, with the following content

export default {
  desc: "Generated migration",
  async up() {},
  async down() {},
};

You'll just have to fill the desc field, as well as the up and down functions. Always keep in mind performance when doing so. If you are performing multiple writes at once, it's a good idea to batch them in a transaction.

Run

yarn task migrate:up

It'll check in the graph DB a Version node and try to run the up methods of the migrations added after said version.

Revert

yarn task migrate:down

It'll run the down method of the most recent migration and update the Version node

About

Demonstrating our approach to performing migrations on our Memgraph DB. Extracted from Community Search's backend

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published