Skip to content

Muzain187/tg_migrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tg_migrator

tg_migrator is a migration tool for managing schema changes in graph databases, specifically designed to work with Tigergraph. Inspired by Alembic, tg_migrator offers a familiar interface for those who have worked with database migration tools in the SQL world but tailored for the unique requirements of graph databases.

Table of Contents

Introduction

tg_migrator helps you to version control your Tigergraph schema changes. Whether you're working on a single project or across multiple environments, tg_migrator ensures that your graph schema changes are tracked and reproducible.

Features

  • Schema Versioning: Track changes to your graph schema over time.
  • Rollback Support: Easily revert changes if something goes wrong.
  • Environment Agnostic: Manage migrations in development, testing, and production environments.
  • CLI Interface: Command-line tools to simplify migration tasks.

Installation

Install tg_migrator using pip:

cd dist
# choose tg_migrator version wheel file updated one
pip install tg_migrator-0.1.2-py3-none-any.whl
pip install tg_migrator

Quick Start

To quickly get started with tg_migrator, follow these steps:

  1. Initialize Migration Directory:

    tg_migrator init
  2. Create a New Migration:

    tg_migrator create_version -m "Create vertex abc"
  3. Apply Migrations:

    tg_migrator upgrade all

Usage

Version Management

tg_migrator uses a graph-based approach to manage migration versions:

Vertex: Each migration is represented as a tg_migrator vertex. Edges: next_version: Points to the next migration version. previous_version: Points to the previous migration version. active: Each migration vertex holds a status indicating whether it has been applied or not.

Example Schema

version_tree

schema

Creating Migrations

Create a new migration file with a descriptive message:

tg_migrator create -m "Add new vertex type User"

This will generate a new migration script in your versions directory.

Applying Migrations

To apply all pending migrations, run:

tg_migrator upgrade all

This will bring your database schema up to date with the latest changes.

Rolling Back Migrations

To roll back the most recent migration, specify a specific version to downgrade to:

tg_migrator downgrade <version>

Configuration

Configuration options can be specified in a configuration file or via environment variables. Here is an example configuration file:

[tg_migrator]
host_name = http://localhost:9000
secret = secret
tg_cloud = False
graph_name = graph_name

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Created by Mohammad Ashraf. You can reach me at [[email protected]].

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages