Giter Site home page Giter Site logo

orbit-love / mg-migrations-showcase Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 28 KB

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

License: MIT License

JavaScript 100.00%
memgraph migrations

mg-migrations-showcase's Introduction

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

mg-migrations-showcase's People

Contributors

steeve-orbit avatar

Stargazers

Kruno Golubic avatar  avatar Nicolas Goutay avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.