You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

node-liquibase

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-liquibase

Node.js wrapper for Liquibase

4.1.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

Website Website Twitter Follow npm npm GitHub repo size

Use Node.js and databases? Want to do smart architecture decisions? Do not invent wheel, use Liquibase. Liquibase is an open-source database-independent library for tracking, managing and applying database schema changes.

Installation

There is an easy way to integrate Liquibase power to Node.js application. All you need is npm package.

$ npm install --save liquibase

Usage

Liquibase support rich pool of commands to keep your database up-to-date, like update, rollback, diff check out full list here: https://docs.liquibase.com/commands/home.html.

CLI

You can use this NPM package as a CLI tool under the namespace node-liquibase if you wish.

Example

Bundled Liquibase Executable
node-liquibase
--changeLogFile="/examples/change-log-examples/postgreSQL/changelog.xml"
--url="jdbc:postgresql://localhost:5432/postgres"
--username="yourusername"
--password="yoursecurepassword"
--classpath="/Users/taylor/Dev/Liquibase/hackathons/node-liquibase/drivers/postgresql-42.2.8.jar"
status
Alternative Liquibase Executable
node-liquibase /Users/taylor/Dev/Liquibase/hackathons/node-liquibase/bin/liquibase/liquibase
 --changeLogFile="/examples/change-log-examples/postgreSQL/changelog.xml"
 --url="jdbc:postgresql://localhost:5432/postgres"
 --username="yourusername"
 --password="yoursecurepassword"
 --classpath="/Users/taylor/Dev/Liquibase/hackathons/node-liquibase/drivers/postgresql-42.2.8.jar"
 status

In Your Project Files

TypeScript

import { LiquibaseConfig, Liquibase, POSTGRESQL_DEFAULT_CONFIG } from 'node-liquibase'

const myConfig: LiquibaseConfig = {
	...POSTGRESQL_DEFAULT_CONFIG,
	url: 'jdbc:postgresql://localhost:5432/node_liquibase_testing',
	username: 'yourusername',
	password: 'yoursecurepassword',
}
const instance = new Liquibase(myConfig);

async function doEet() {
	await instance.status();
	// await instance.update();
	// await instance.dropAll();
}

doEet();

JavaScript

From the index.js file adjust "<>" fields accordingly:

const fromLibrary = require('node-liquibase/cjs/index');
const POSTGRESQL_DEFAULT_CONFIG = require('node-liquibase/cjs/constants/defaults/postgresql-default.config').POSTGRESQL_DEFAULT_CONFIG;

const myConfig = {
	changeLogFile: POSTGRESQL_DEFAULT_CONFIG.changeLogFile,
	classpath: POSTGRESQL_DEFAULT_CONFIG.classpath,
	url: 'jdbc:postgresql://localhost:5432/node_liquibase_testing',
	username: 'yourusername',
	password: 'yoursecurepassword',
}

const instance = new fromLibrary.Liquibase(myConfig);

doEet();


async function doEet() {
	await instance.status();
	// await instance.update();
	// await instance.dropAll();
}

Want to help?

This project needs some work on the infrastructure and build tooling side. For now the workflow to test an 'end user ready' version of the project, you'll first need to build/compile the code, and then you can run it using the Node CLI's REPL node path/to/something.js.

There is an issue in path resolution within THIS application code in addition to the complexities in Liquibase Core. Until this is resolved the resolved path for the Liquibase executable will differ between compiled and source code. This will affect your experience if you try to transpile the code on the fly using ts-node. I have not resolved the issue yet.

Build

To build all of the things:

yarn build

Tests

Run tests with:

yarn test

Env Vars

To substitute your own user/pass for a given environment, make a copy of .env.example in root directory as .env and update accordingly.

Keywords

liquibase

FAQs

Package last updated on 20 Apr 2021

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