Alongside with command line, you can use node-pg-migrate
also programmatically. It exports runner function,
which takes options argument with following structure (similar to command line arguments):
databaseUrl
[string or object] - Connection string or client config which is passed to new pg.Client- or
dbClient
[pg.Client] - instance of new pg.Client. Instance should be connected to DB and after finishing migration, user is responsible to close connection migrationsTable
[string] - The table storing which migrations have been runmigrationsSchema
[string] - The schema storing table which migrations have been run (defaults to same value asschema
)schema
[string or array of strings] - The schema on which migration will be run (defaults topublic
)dir
[string] - The directory containing your migration filescheckOrder
[boolean] - Check order of migrations before running themdirection
[enum] -up
ordown
count
[number] - Number of migration to runtimestamp
[boolean] - Treatscount
as timestampignorePattern
[string] - Regex pattern for file names to ignore (ignores files starting with.
by default)file
[string] - Run only migration with this namesingleTransaction
[boolean] - Combines all pending migrations into a single transaction so that if any migration fails, all will be rolled back (defaults totrue
)createSchema
[boolean] - Creates the configured schema if it doesn't existcreateMigrationsSchema
[boolean] - Creates the configured migration schema if it doesn't existnoLock
[boolean] - Disables locking mechanism and checksfake
[boolean] - Mark migrations as run without actually performing them (use with caution!)dryRun
[boolean]log
[function] - Redirect log messages to this function, rather thanconsole
logger
[object with debug/info/warn/error methods] - Redirect messages to this logger object, rather thanconsole
decamelize
[boolean] - Runsdecamelize
on table/column/etc. names (experimental)