Giter VIP home page Giter VIP logo

migrate's Introduction

migrate

A simple language agnostic database migration tool

Migrations are applied in batches called a revision. A revision is represented by a folder named in consecutive numerical order, starting from "1". Each revision contains pairs of migration scripts with extensions .up.sql and .down.sql for upgrading and downgrading the database respectively.

install

$ pip install migrate

usage

usage: migrate [options] <command>

examples

move into working directory and create default migrations folder

$ cd /path/to/project
$ mkdir migrations

creating a migration

$ migrate create -e sqlite3 -d /path/to/test.db -m "create users table"

this generates the up and down files using the current timestamp and message in the current revision folder

$ ls -R migrations/
1

migrations//1:
20141215134002_create_users_table.down.sql	20141215134002_create_users_table.up.sql

upgrading from current revision

    $ migrate up -e sqlite3 -d test.db

rolling back current revision

$ migrate down -e sqlite3 -d test.db

running with sample configuration example: config.ini

[dev]
database = /path/to/test.db
engine = sqlite3

[prod]
migration_path = /path/to/prod/migrations
database = DB_NAME
user = DB_USER
password = DB_PASSWORD
host = DB_HOST
engine = ENGINE

execute with configuration for a particular revision using a preferred environment

$ migrate reset -f config.ini --env prod

you may put a .migrate configuration file in INI format in your project directory to be used by default

commands

Command Description
create Create a migration. Specify "--rev 0" to add a new revision
up Upgrade from a revision to the latest
down Downgrade from the latest to a lower revision
reset Rollback and re-run to the current revision

Any migration operation will stop when errors are encountered in any of the scripts. To ignore errors use the --skip-errors option.

For more options

$ migrate -h

license

MIT

migrate's People

Contributors

gim- avatar kofrasa avatar vkvych avatar

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.