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.
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.
- 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.
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
To quickly get started with tg_migrator
, follow these steps:
-
Initialize Migration Directory:
tg_migrator init
-
Create a New Migration:
tg_migrator create_version -m "Create vertex abc"
-
Apply Migrations:
tg_migrator upgrade all
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.
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.
To apply all pending migrations, run:
tg_migrator upgrade all
This will bring your database schema up to date with the latest changes.
To roll back the most recent migration, specify a specific version to downgrade to:
tg_migrator downgrade <version>
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
This project is licensed under the MIT License. See the LICENSE file for details.
Created by Mohammad Ashraf. You can reach me at [[email protected]].