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.ClientmigrationsTable[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] - 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] -upordowncount[number] - Number of migration to runtimestamp[boolean] - Treatscountas timestampignorePattern[string] - Regex pattern for file names to ignorefile[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 checksdryRun[boolean]log[function] - Redirect log messages to this function, rather thanconsole.log