Skip to content

Latest commit

 

History

History
26 lines (24 loc) · 2.23 KB

api.md

File metadata and controls

26 lines (24 loc) · 2.23 KB

Programmatic API

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 run
  • migrationsSchema [string] - The schema storing table which migrations have been run (defaults to same value as schema)
  • schema [string or array of strings] - The schema on which migration will be run (defaults to public)
  • dir [string] - The directory containing your migration files
  • checkOrder [boolean] - Check order of migrations before running them
  • direction [enum] - up or down
  • count [number] - Number of migration to run
  • timestamp [boolean] - Treats count as timestamp
  • ignorePattern [string] - Regex pattern for file names to ignore (ignores files starting with . by default)
  • file [string] - Run only migration with this name
  • singleTransaction [boolean] - Combines all pending migrations into a single transaction so that if any migration fails, all will be rolled back (defaults to true)
  • createSchema [boolean] - Creates the configured schema if it doesn't exist
  • createMigrationsSchema [boolean] - Creates the configured migration schema if it doesn't exist
  • noLock [boolean] - Disables locking mechanism and checks
  • fake [boolean] - Mark migrations as run without actually performing them (use with caution!)
  • dryRun [boolean]
  • log [function] - Redirect log messages to this function, rather than console
  • logger [object with debug/info/warn/error methods] - Redirect messages to this logger object, rather than console
  • decamelize [boolean] - Runs decamelize on table/column/etc. names (experimental)