Skip to content

Latest commit

 

History

History
139 lines (97 loc) · 4.85 KB

API.md

File metadata and controls

139 lines (97 loc) · 4.85 KB

Table of Contents

PgMigrate

pg-migrate.js:51-64

PgMigrate

Parameters

  • options Object object
    • options.database string database to apply migrations
    • options.host string database host (optional, default 'localhost')
    • options.port int database port (optional, default 5432)
    • options.user string database user
    • options.password string database password
    • options.schemaName string database migrations table schema (optional, default 'public')
    • options.tableName string database migrations table name (optional, default 'migrations')
    • options.migrationsDir string path to migrations dir (optional, default './migrations')
    • options.attachMonitor boolean attach pg-monitor (optional, default false)

Examples

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

Returns Promise

connect

pg-migrate.js:77-83

connect prepares database and reads migrations

Examples

const PgMigrate = require('@urbica/pg-migrate');
const pgMigrate = new PgMigrate();
pgMigrate.connect();

Returns Promise

migrate

pg-migrate.js:118-142

migrate runs migrations

Examples

const PgMigrate = require('@urbica/pg-migrate');
const pgMigrate = new PgMigrate();
pgMigrate
 .connect()
 .then(() => pgMigrate.migrate());

Returns Promise

rollback

pg-migrate.js:158-182

rollback rollbacks migrations

Parameters

  • limit int number of migrations to rollback (optional, default 1)

Examples

const PgMigrate = require('@urbica/pg-migrate');
const pgMigrate = new PgMigrate();
pgMigrate
 .connect()
 .then(() => pgMigrate.rollback(1));

Returns Promise

reset

pg-migrate.js:197-219

reset rollbacks all migrations

Examples

const PgMigrate = require('@urbica/pg-migrate');
const pgMigrate = new PgMigrate();
pgMigrate
 .connect()
 .then(() => pgMigrate.reset());

Returns Promise

end

pg-migrate.js:234-236

end closes database connection

Examples

const PgMigrate = require('@urbica/pg-migrate');
const pgMigrate = new PgMigrate();
pgMigrate
 .connect()
 .then(() => pgMigrate.end());

Returns Promise