Skip to main content

Managing migrations

Kineo provides an official migration manager, called KineoKit. You can install it with one of these commands:

npm install kineokit -D

You can then run kineo or kineokit through your package manager.

Getting Started

KineoKit requires a bit of configuration, which can be initialized using kineokit init. We recommend that you set up your client and schema first.

kineokit init

You can also set up KineoKit manually. Create a kineo.config.ts at the root of your project, and paste these contents:

import { defineConfig } from "kineokit";
import { neo4jKit } from "kineokit/adapters/neo4j"; // placeholder
import { db } from "@/db/client"; // placeholder
import { schema } from "@/db/schema"; // placeholder

export default defineConfig({
adapter: neo4jKit(db), // placeholder
client,
schema,
});

Replace all placeholders with the right configuration for your project.

CLI commands

kineokit push

Pushes a schema to the database, skipping writing migrations to the database, warning you for breaking changes which may cause data loss.

  • Options:
    • --force, -f: ignores breaking changes. This may cause data loss.

kineokit pull

Pulls a schema from the database, and puts it in your code.

danger

Make sure you only run this command with a clean worktree, as this will replace your current schema code.

  • Options:
    • --force, -f: ignores warnings, including if the adapter doesn't support pulling the entire schema. This may cause code loss, if you don't have a clean worktree.

kineokit migrate

Generates migrations, and, by default, pushes them to the database.

  • Aliases: kineokit generate
  • Options:
    • --no-push, -n: Doesn't push the migrations to the database, only creates them on disk.

kineokit status

Gets the status of all migrations.

kineokit deploy

Deploys all migrations that haven't been deployed yet.

kineokit rollback

Rolls back a certain number of migrations by creating a new migration.

  • Arguments:
    • #1: n: The amount of migrations to roll back.