Coder Social home page Coder Social logo

go-migrations's Introduction

go-migrations

If you are looking for a tool do apply database migration written in GO look here https://github.com/golang-migrate/migrate.

In contrast to the repo above, this repo is very use case specific and (therefore) not as rich in drivers and functionality as the above mentioned.

Migration Layout

An example of a migration structure can be found in the example folder ./example.

Folder names starting with an underscore generally have a special meaning. Currently the following special folders exist:

  • _environments: This folder contains configuration files for different databases / environments

The general layout looks like the following:

.
│   docker-compose.yaml: Optional. Only required for local development
│
└─── migrations: `./migrations` is the default location, but it can be any other folder as well
│   └─── _environments: see remarks above
│       │   development.yaml
│       │   production.yaml
│       │   ...
│   └─── <some_folder>: Any name is possible (typically represents a sub app of a database, just used for better grouping of migrations)
│       │   20171101000001_my_migration.sql
│       │   ...
|       └─── verify
│           │   20171101000001_my_migration.sql
│           │   ...

Config Layout

Configuration files, which are stored in the _environments folder (see migration layout). These files look like this

db_type: postgres
host: localhost
port: 35434
db_name: my_db
user: admin
password: admin_pass

Commands

The migration tool includes a --help flag, which can be called on the tools itself or on any subcommand:

./go_migrations --help
./go_migrations start --help
...

Installation

make build
sudo cp db-migrations /usr/local/bin/db-migrations
chmod +x /usr/local/bin/db-migrations

Shell Completion

Bash

sudo cp ./shell_complete/bash_autocomplete.txt /etc/bash_completion.d/db-migrations

Zsh

mkdir -p ~/.config/db-migrations/
cp shell_complete/zsh_autocomplete.txt ~/.config/db-migrations


echo "" >> ~/.zshrc
echo "# auto completion for db-migrations" >> ~/.zshrc
echo "PROG=db-migrations" >> ~/.zshrc
echo "_CLI_ZSH_AUTOCOMPLETE_HACK=1" >> ~/.zshrc
echo "source  ~/.config/db-migrations/zsh_autocomplete.txt" >> ~/.zshrc
echo "" >> ~/.zshrc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.