leaf-migration-codegen

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 5 Imported by: 0

README

Leaf Migration Code Generator

This repository contains code generator for leaf migration.

Prerequisites

  1. Go 1.18

Installation

  1. Clone this repository
$ git clone https://github.com/enricodg/leaf-migration-codegen
  1. Go to the directory, and install dependencies and binaries
$ cd leaf-migration-codegen
$ go mod tidy
$ go install
  1. You should be able to use the CLI by using leaf-migration-codegen
$ leaf-migration-codegen
NAME:
   Leaf migration codegen - Supporting leaf framework to initialize migration project

USAGE:
   leaf-migration-codegen command [command options] [arguments...]

VERSION:
   v1.0.0

DESCRIPTION:
   CLI Leaf migration code generator

COMMANDS:
   init      init --project <project URL>
   generate  generate --types <type> --name <name>
   new       new --types <type> --name <name>
   help, h   Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

Usage

1. Initialize Project

Create your directory / git repository and pass the value to init command, example:

$ leaf-migration-codegen init --project github.com/enricodg/leaf-migration-example
2. Generate Files

Currently it only supports service parameter generation. Service parameter is used to change service configuration on the fly without restarting the service.

$ leaf-migration-codegen generate --types <mysql | postgre | mongo> --name <service_parameters>
3. Generate Migration

Leaf migration currently supports 3 databases (MongoDB, PostgreSQL, and MySQL), in order to specify which type of database migration you want to create please use --types flag. To name the migration file, use the --name flag.

$ leaf-migration-codegen new --types <mysql | postgre | mongo> --name what_to_add_or_remove
4. Migrate

After you've done all the steps above, you can directly use the migration files to migrate, rollback, and check the version of your migration. If you want to migrate specific version only, use the --specific flag or otherwise it will migrate all available migrations.

To migrate, use the following command:

$ go run main.go migrate [--types <mysql | postgre | mongo>] [--specific] [--verbose]
5. Rollback

If you don't specify which version to rollback (--specific flag) it will rollback the migration until the version that you mentioned.

To rollback, use the following command:

$ go run main.go rollback --types [mysql | postgre | mongo] --version <version number> [--specific] [--verbose]
6. Check Migration

To check, use the following command:

$ go run main.go check [--types <mysql | postgre | mongo> [--version <version number>]

Feel free to contribute to the project by creating issue or pull request. :)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL