1.0.1 • Published 5 years ago

@mmckelvy/run-pg-script v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

run-pg-script

Run Postgres scripts using psql the right way.

Applies the appropriate options for running scripts through psql.

Installation

npm install @mmckelvy/run-pg-script

Usage

const runPgScript = require('run-pg-script');

runPgScript({
  dbName: 'my-db',
  file: `${__dirname}/schema/base-schema.sql`)
});

Default options

Runs your scripts using the following psql options:

--no-psqlrc: No need for custom formatting if you're just running a script.

--set ON_ERROR_STOP=1: Stop the script if there's an error.

--pset pager=off: No need for a pager when we're running a script.

--single-transaction: Run the script as a single transaction.