Giter Site home page Giter Site logo

pg-migrate's Introduction

Urbica PG Migrate

npm version npm downloads CI

PostgreSQL migration tool.

Documentation.

Screenshot

Installation

pg-migrate requires node v7.6.0 or higher for ES2015 and async function support.

npm install -g @urbica/pg-migrate

...or build from source

git clone https://github.com/urbica/pg-migrate.git
cd pg-migrate
npm install

Usage

Usage:
  pg-migrate [options] new <name>
  pg-migrate [options] migrate
  pg-migrate [options] rollback <N>
  pg-migrate [options] reset
  pg-migrate --help
  pg-migrate --version

Examples:
  pg-migrate new create-users
  pg-migrate migrate
  pg-migrate rollback 1
  pg-migrate reset

Options:
  --help                        Show this screen
  --version                     Show version
  --verbose                     Show verbose output
  -m --migrations-dir=DIR       The directory containing your migration files [default: ./migrations]
  -t --migrations-table=TABLE   Set the name of the migrations table          [default: migrations]
  -s --migrations-schema=SCHEMA Set the name of the migrations table scheme   [default: public]

Connection options:
  -c --connection=DATABASE_URL        database connection string in libpq format
  -d --db=PGDATABASE                  database name to connect to
  -h --host=PGHOST                    database server host or socket directory      [default: localhost]
  -p --port=PGPORT                    database server port                          [default: 5432]
  -U --user=PGUSER                    database user name
  -W --password=PGPASSWORD            database user name password

Node.js API

Using Promises

const PgMigrate = require('@urbica/pg-migrate');
const pgMigrate = new PgMigrate({
  database: 'test',
  migrationsDir: './migrations'
});

pgMigrate
  .connect()
  .then(() => pgMigrate.migrate())
  .then(() => pgMigrate.end());

...or using async/await

const pgMigrate = new PgMigrate({ database, user, migrationsDir });

async function migrate() {
  await pgMigrate.connect();
  await pgMigrate.migrate();
  await pgMigrate.end();
}

migrate();

See API for more info.

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.