node-liquibase
Peer Dependency
If you prefer to make use of a peer dependency experience, we offer a version of node-liquibase
that does not bundle an associated version of Liquibase.
Install Instructions
-
In order to use this
p[eer]-d[ependency]
version ofnode-liquibase
you can install with:yarn add liquibase@pd
or
npm i liquibase@pd
-
Once installation is complete you can begin Using Liquibase with Node.js.
Points to remember
- Depending on your implementation method of choice (TS, JS, or CLI), you will need to let
node-liquibase
know where it can find your Liquibase executable. This should be an absolute path to the executable. - The bundled drivers were removed from the @pd release to further reduce the size of your node_modules. There is a chance you will need to update your configurations to provide an absolute path on the classpath property to the drivers you need.
- To substitute your own user/pass for a given environment, make a copy of .env.example in the root directory as .env and update accordingly.
Configuration Updates for TypeScript or JavaScript
To configure your updates for TypeScript or JavaScript you must add the liquibase
property to your configuration.
import { Liquibase, LiquibaseConfig, POSTGRESQL_DEFAULT_CONFIG } from 'liquibase';
const myConfig: LiquibaseConfig = {
...POSTGRESQL_DEFAULT_CONFIG,
changeLogFile: './changelog.xml',
url: 'jdbc:postgresql://localhost:5432/node_liquibase_testing',
username: 'yourusername',
password: 'yoursecurepassword',
liquibase: 'Users/me/absolute/path/to/executable/directory'
}
const inst = new Liquibase(myConfig);
inst.status();
Configuration Updates (CLI)
To configure your updates and add the --liquibase
flag via the CLI you must add Users/me/absolute/path/to/executable/directory
to your configuration.
After
yarn node-liquibase --liquibase="Users/me/absolute/path/to/executable/directory" --changeLogFile="changelog.xml"
--url="jdbc:postgresql://localhost:5432/node_liquibase_testing"
--username="yourusername"
--password="yoursecurepassword"
--classpath="/Users/me/path/to/my/db-drivers/postgresql-42.4.2.jar" status</pre>
yarn node-liquibase --liquibase="Users/me/absolute/path/to/executable/directory" --changeLogFile="changelog.xml" --url="jdbc:postgresql://localhost:5432/node_liquibase_testing" --username="yourusername" --password="yoursecurepassword" --classpath="/Users/me/path/to/my/db-drivers/postgresql-42.4.2.jar" status
Sandbox: @pd
If you'd like an example of a working setup of Liquibase@pd be sure to check out the peer-dependency branch of the Node Liquibase Sandbox. Here is a diff of the two approaches (Bundled v. Peer)