Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
pg-migrations
Advanced tools
The purpose of this library is to provide liquibase
like migration capabilities as a node
module and command line interface.
npm install --global pg-migrations
liquibase
provides many ways of managing migrations including xml
, json
, yaml
, and sql
formats for multiple database engines. However, these options can add to complexity, and unfortunately requires java
to run.
The purpose of pg-migrations
is to provide a simpler way (with fewer options) for managing postgresql
database migrations without requiring java
.
pg-migrations
works with either a schema configuration file (either yaml
, or json
), or a directory.
The schema configuration file lists all the files to execute as part of the migration. Files can be defined as glob
expressions and files matching the glob
expression are executed in alpha numeric order (i.e. 1
< 2
< 10
).
Example schema configuration file (example/database/schema.yml
):
files:
- '**/*.sql'
When a directory is used as an input to the migration, it effectively uses the same configuration as provided above (i.e. executes all sql
files in the directory in alpha numeric order).
A migration file must start with --migration
on the first line and contains one or many changeset
s (sql
statements) preceded by a --changeset
comment.
A changeset
comment takes the following format:
--changeset [changeset name] [type:<once|always|change>] [context:<comma,separated,list>]
Where:
changeset name
- (optional) name of the changeset, must be unique within the filetype
- (optional) execution type of the changeset, must be either execute once
, always
, or on change
once
once
migration script cannot be modified after it has already been executed (will result in an error on subsequent migrations)context
- (optional) list of contexts that the changeset should be executed under
--context
command line argument, the omission of the --context
argument implies all contexts will be executedExample:
--migration
--changeset create table
create table my_table (
val text
);
--changeset test data context:test
insert into my_table (val)
values ('test data');
Usage: pg-migration <schema file|directory> [options]
Database migration tool for postgres databases
Options:
-h, --help output usage information
-V, --version output the version number
-c, --connection <connection string> database connection string (required)
-u, --user <user> database user name
-p, --password <password> database password
-P, --prompt-password prompt for database password
-s, --generate-script output sql script instead of executing the migration
--context [contexts] changeset contexts to execute
pg-migration database/schema.yml -c postgres://postgres@localhost/postgres -p password
FAQs
Postgres database migration utility
The npm package pg-migrations receives a total of 0 weekly downloads. As such, pg-migrations popularity was classified as not popular.
We found that pg-migrations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.