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.

pg-migrate's People

Contributors

greenkeeper[bot] avatar stepankuzmin avatar dependabot[bot] avatar safinn avatar snyk-bot avatar vitaly-t avatar device25 avatar

Stargazers

Thibaud REY avatar Antonio Moura avatar Cioclea Doru Octavian avatar Klaus Badelt avatar Nick Reese avatar Leonard Oduneye avatar Can Rau avatar Camille Louédoc-Eyriès avatar Daan Aerts avatar Nathan Probst avatar Adam Hanna avatar Eingress Ltd avatar Pedro Campos Vaz avatar Bernardo Amorim avatar Mark Larah avatar Nicolas LAURENT avatar incessantmeraki avatar Gireg de Kerdanet avatar Casper Olsen avatar  avatar Ajinkya Patil avatar Benjamin Flesch avatar Dan Loewenherz avatar Dario A Lencina-Talarico avatar Eugene avatar Ovidiu Cherecheș avatar HrOokami avatar Andrew Burdyug avatar  avatar Julien Tregoat avatar YoungHappy avatar Jason Morganson avatar Erdong avatar Thomas Gratier avatar Tatiana Ivannikova avatar  avatar Taya Lav avatar Lena  avatar Andrey Tyukavin avatar  avatar Jiu LianCheng avatar  avatar Andrey avatar Sergey avatar  avatar

Watchers

James Cloos avatar Andrey avatar Kieran Harper avatar Yared Getachew avatar Sergey avatar  avatar

pg-migrate's Issues

SSL defaults to "false", which is not a valid value.

Hello,

I think that because the -ssl option is not a flag but an option, docopt generates the string value 'false' when it's not present.
This is not a legal value for that option (need conversion to a boolean). Furthermore, because the string 'false' is truthy,
we can't provide the option via environment variables.

...
// Environment variables never get used because opt is the string "false" 
ssl: opt['--ssl'] || process.env.PGSSL || process.env.POSTGRES_SSL
...

Thanks for the otherwise nice library.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

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.