Simple Migration Tool - written in Go

Pravasan

Simple Migration tool intend to be used for any languages, for any db.

Build Status

Please feel free to criticize, comment, etc. Currently this is working for MySQL, PostgreSQL. Soon will be available for other Databases too.

Definition in Hindi


प्रवसन {pravasan} = MIGRATION(Noun)

Install

  1. Choose proper OS & Download from http://pravasan.github.io/pravasan/#download
  2. Unzip / Untar the file downloaded
  3. For some OS its default but some it needs to be explicit add chmod +x pravasan_*
  4. Look at the below Usage and start using it from the folder where you would like to execute & store migration files.

Usage

Syntax

pravasan [<flags>] <action> <sub-action> [data input]

Flags

Usage of pravasan:
  -autoAddColumns="": Add default columns when table is created
  -confOutput="json": config file format: json, xml
  -d="": database name
  -dbType="mysql": database type
  -h="localhost": database hostname
  -indexPrefix="idx": prefix for creating Indexes
  -indexSuffix="": suffix for creating Indexes
  -migDir="./": migration file stored directory
  -migFileExtn="prvsn": migration file extension
  -migFilePrefix="": prefix for migration file
  -migOutput="json": current supported format: json, xml
  -migTableName="schema_migrations": migration table name
  -p=false: database password
  -port="5432": database port
  -storeDirectSQL=true: Store SQL in migration file instead of XML / JSON
  -u="": database username
  -version=false: print Pravasan version

To create the configuration file use either of the below commands & pravasan.conf.json / pravasan.conf.xml will be created

pravasan -u="root" -p -dbType="mysql" -d="testdb" -h="localhost" -port="5433" create conf 
pravasan -u=root -p -dbType=postgres -d=testdb -h=localhost -port=5433 -output=xml create conf 

Assuming the pravasan.conf.json or pravasan.conf.xml file is set already

pravasan add add_column test123 id:int
pravasan a ac test123 id:int                                     # Same as above

pravasan add add_index test123 id order name

pravasan add create_table test123 id:int name:string order:int status:bool
pravasan a ct test123 id:int name:string order:int status:bool              # Same as above

pravasan add drop_column test123 id
pravasan add drop_index test123 id order name
pravasan add rename_table test123 new_test123
pravasan add sql                                           # to add SQL statements directly.

pravasan down [-1]
pravasan up
pravasan up 20150103174227, 20150103174333

If you like not to store the credentials in file then use it like this

pravasan -u=root -p -dbType=postgres -d=testdb -h=localhost -port=5433 up 20150103174227

Work in progress are:

  • Support for Oracle, MongoDB, etc.,

High Level Features

  • Create & read from Conf file (XML / JSON)
  • Output in XML, JSON format
  • Support for Direct SQL Statements
  • Support for MySQL, Postgres
  • Temporarily SQLite3 is stopped - due to compile issue.

All Features / Bugs

Few Other Notes:

Details

Add few columns by default during creation of a table.

$ pravasan -autoAddColumns: id:int created_at:datetime modified_at:datetime create conf

The above command will add the 3 columns id, created_at, modified_at will be stored in configuration & will get added during any create_table statements.

To store direct sql in JSON or XML format

$ pravasan -storeDirectSQL a ct test123 id:int

The above command will add (a) a migration & will generate create_table (ct) action with the table name test123 with only one column id of datatype int as SQL into the JSON (by default) or XML if there is an configuration file present and set XML to generate.

To get the list of datatypes supported

$ pravasan list datatypes           # All databases
$ pravasan l dt                     # All databases
$ pravasan list dt postgresql       # Will list datatypes supported by PostgreSQL
$ pravasan list datatypes sqlite3   # Will list datatypes supported by SQLite3
$ pravasan l dt mysql               # Will list datatypes supported by MySQL

Below is the sample output for the above last command.

+-------------------+-----------------------+--------------+
|     DATATYPE      | SUPPORTED DATABASE(S) |    ALIAS     |
+-------------------+-----------------------+--------------+
| VARCHAR           | MySQL                 |              |
| VARBINARY         | MySQL                 |              |
| MEDIUMBLOB        | MySQL                 |              |
| LONGBLOB          | MySQL                 |              |
| DATE              | MySQL                 |              |
| REAL              | MySQL                 |              |
| DEC               | MySQL                 | DECIMAL      |
| NUMERIC           | MySQL                 | DECIMAL      |
| STRING            | MySQL                 | VARCHAR(255) |
Similar Resources

Database migration through structures - development

goMigration 基于 Golang 的数据库迁移工具,目前仍在开发中,有兴趣的小伙伴可以联系我一起~ 食用方法 go get https://github.com/DGuang21/goMigration 手动将其安装 可通过 gom gen create_c_user_table 方法生

Dec 2, 2021

A migration engine to deploy database changes in your golang + mongodb app.

bisonmigration A migration engine to deploy database changes in your golang + mongodb app. Migration files register their UP and DOWN functions in the

Jan 30, 2022

goydb, a couchdb compatible embeddable database written in go

goydb, a couchdb compatible embeddable database written in go

goydb, a couchdb compatible embeddable database written in go Getting started (not embedded) Using docker mkdir data docker run -e GOYDB_ADMINS=admin:

Sep 14, 2022

entimport is a tool for creating Ent schemas from existing SQL databases.

entimport entimport is a tool for creating Ent schemas from existing SQL databases. Currently, MySQL and PostgreSQL are supported. The tool can import

Dec 23, 2022

Opinionated tool for database structure management and migrations

trek Requirements At least version 13 of postgres is needed. Installation go install . Setup Create config.yaml: model_name: model_name db_name: db

Dec 14, 2022

Tool to handle versioned migrations with gorm

GORM Migrations About Gorm Migrations Gorm Migrations is a tool designed for go-gorm. Gorm Migration takes the pain out of development of migrations v

Mar 14, 2022

Migration - Commonly used migration tools

Migration Commonly used migration tools Usage package main import ( "context"

Feb 16, 2022

Migration - Commonly used migration tools

Migration Commonly used migration tools Usage package main import ( "context"

Feb 16, 2022

Simple Migration Tool - written in Go

Pravasan Simple Migration tool intend to be used for any languages, for any db. Please feel free to criticize, comment, etc. Currently this is working

Sep 26, 2022

A database migration tool written in Go.

dbmagritte created by Austin Poor A database migration tool written in Go. Usage Commands: init: Set up the repo by creating a .dbmagritte.yaml file a

Jan 29, 2022

Terraform-equinix-migration-tool - Tool to migrate code from Equinix Metal terraform provider to Equinix terraform provider

Equinix Terraform Provider Migration Tool This tool targets a terraform working

Feb 15, 2022

Simple migration tool for MySQL

prrn Simple migration tool for MySQL This is a CLI that helps you create a DB migration file. There is no need to write up and down files from scratch

Nov 10, 2021

Esdump is a migration CLI written in Go for migrating index mapping and data from one elasticsearch to another.

esdump Introduction esdump is a migration CLI written in Go for migrating index mapping and data from one elasticsearch to another. Compatibility Elas

Jul 23, 2022

Goose database migration tool - fork of https://bitbucket.org/liamstask/goose

goose Goose is a database migration tool. Manage your database schema by creating incremental SQL changes or Go functions. Goals of this fork github.c

Dec 30, 2022

SQL schema migration tool for Go.

sql-migrate SQL Schema migration tool for Go. Based on gorp and goose. Using modl? Check out modl-migrate. Features Usable as a CLI tool or as a libra

Jan 2, 2023

Goose database migration tool - fork of https://bitbucket.org/liamstask/goose

goose Goose is a database migration tool. Manage your database schema by creating incremental SQL changes or Go functions. Goals of this fork github.c

Dec 30, 2022

Dbmate is a database migration tool, to keep your database schema in sync across multiple developers and your production servers.

Dbmate is a database migration tool, to keep your database schema in sync across multiple developers and your production servers. It is a stand

Jan 1, 2023

An Elasticsearch Migration Tool.

An Elasticsearch Migration Tool Elasticsearch cross version data migration. Dec 3rd, 2020: [EN] Cross version Elasticsearch data migration with ESM Fe

Dec 19, 2022

Migration tool for ksqlDB, which uses the ksqldb-go client.

Migration tool for ksqlDB, which uses the ksqldb-go client.

ksqldb-migrate Migration tool for ksqlDB, which uses the ksqldb-go client.

Nov 15, 2022
Comments
  • Data Types Definition

    Data Types Definition

    id:int
    id:number
    id:float
    id:int32
    id:int64
    

    etc.,

    Defining master data types and a matrix to be shown in the console for help. e.g.,

    $ pravasan list datatypes
    int - MySQL, Postgres, SQLite
    float - MysQL, Postgres
    string - 
    
Migration - Commonly used migration tools

Migration Commonly used migration tools Usage package main import ( "context"

Feb 16, 2022
Simple Migration Tool - written in Go

Pravasan Simple Migration tool intend to be used for any languages, for any db. Please feel free to criticize, comment, etc. Currently this is working

Sep 26, 2022
A database migration tool written in Go.

dbmagritte created by Austin Poor A database migration tool written in Go. Usage Commands: init: Set up the repo by creating a .dbmagritte.yaml file a

Jan 29, 2022
Simple migration tool for MySQL

prrn Simple migration tool for MySQL This is a CLI that helps you create a DB migration file. There is no need to write up and down files from scratch

Nov 10, 2021
Goose database migration tool - fork of https://bitbucket.org/liamstask/goose

goose Goose is a database migration tool. Manage your database schema by creating incremental SQL changes or Go functions. Goals of this fork github.c

Dec 30, 2022
SQL schema migration tool for Go.

sql-migrate SQL Schema migration tool for Go. Based on gorp and goose. Using modl? Check out modl-migrate. Features Usable as a CLI tool or as a libra

Jan 2, 2023
Dbmate is a database migration tool, to keep your database schema in sync across multiple developers and your production servers.

Dbmate is a database migration tool, to keep your database schema in sync across multiple developers and your production servers. It is a stand

Jan 1, 2023
A tool to compare if terraform provider migration schema snapshot is equal to schema defined in resource code

migration schema comparer for Terraform When develop Terraform provider sometimes we need do some state migration(not schema migration) via StateUpgra

Nov 18, 2021
Dead simple Go database migration library.
Dead simple Go database migration library.

migrator Dead simple Go database migration library. Features Simple code Usage as a library, embeddable and extensible on your behalf Support of any d

Nov 9, 2022
Minimalistic database migration helper for Gorm ORM

Gormigrate Gormigrate is a minimalistic migration helper for Gorm. Gorm already has useful migrate functions, just misses proper schema versioning and

Dec 25, 2022