Giter VIP home page Giter VIP logo

morph's Introduction

What is it?

Morph is a simple tool to migrate databases on PostgreSQL. It supports rollbacking from other versions without requiring the migration files from the previous version. Hence, to migrate to a new version, you only need the migration files from this particular version.

Migration files

Each migration file should be prefixed with a numerical identifier. These identifiers determine the order in which the migrations are going to be ran. Thus, a good way to avoid conflict with other commiters is to prefix it with a timestamp formatted as YYYYMMDDHHMM.

Each migration has two SQL files: one ending with .up.sql and the other by .down.sql, respectively the request to migrate and the one to rollback. Failing to have a .down.sql file will result in an error when attempting to rollback but will not prevent the initial migration.

For example, you could have the following files:

migrations/201603291434_create_users.up.sql

CREATE TABLE users (
       id       serial  PRIMARY KEY,
       username varchar NOT NULL UNIQUE CHECK (username <> ''),
       password varchar NOT NULL CHECK (password <> '')
);

migrations/201603291434_create_users.down.sql

DROP TABLE users;

migrations/201604011203_add_email_to_user.up.sql

ALTER TABLE users ADD COLUMN email varchar;

migrations/201604011203_add_email_to_user.down.sql

ALTER TABLE users DROP COLUMN email;

Options

See morph --help for details about command-line options.

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.