Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

pg-migration

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-migration

Apply changesets of your data structure for Postgresql easily from your node application

latest
Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
9
800%
Maintainers
1
Weekly downloads
 
Created
Source

pg-migration

What is it?

NodeJS lacks support for good proper ORMs, and most ORMs tend to suck a bit in the end anyway. For inventid I therefore developed this simple nodejs version for postgresql of Liquibase. It is based on the excellent node-postgres library.

The database changelog table

pg-migration will automatically create the table (dbchangelog) for you.

How to use

  • Import the library import migration from 'pg-migration';
  • Configure the library: const migrateAndStart = migration({ log: (level, message) => { your logging code here } })
  • Create a valid database client connection
  • Create the migration, with that client, and a callback to the server start (e.g. migrateAndStart(db, './migrations', startServer);)

Files called README.md and dbchangelog.sql from the migrations folder are ignored.

Since the changeset id is derived from the file name, you can use the following command to create a new one

touch `date +%Y%m%d%H%M%S`.sql

Please be careful that the files will be executed in a alphabetically sorted fashion, so ensure that files do not depend on anything later (it's really a poor mans Liquibase).

Keywords

postgresql

FAQs

Package last updated on 21 Apr 2018

Did you know?

Socket

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.

Install

Related posts