diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000..51e5d90
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,18 @@
+### Context
+#### Node-Liquibase Version
+
+#### Liquibase Version (if not bundled)
+
+### Description
+
+[Description of the bug or feature]
+
+### Steps to Reproduce
+
+1. [First Step]
+2. [Second Step]
+3. [and so on...]
+
+**Expected behavior:** [What you expected to happen]
+
+**Actual behavior:** [What actually happened]
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..4c1644e
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,17 @@
+### All Submissions:
+
+* [ ] Have you followed the guidelines in our Contributing document?
+* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update/change?
+
+
+
+### New Feature Submissions:
+
+1. [ ] Does your submission pass tests?
+2. [ ] Have you lint your code locally prior to submission?
+
+### Changes to Core Features:
+
+* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
+* [ ] Have you written new tests for your core changes, as applicable?
+* [ ] Have you successfully ran tests with your changes locally?
diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml
new file mode 100644
index 0000000..33048a6
--- /dev/null
+++ b/.github/workflows/node.js.yml
@@ -0,0 +1,54 @@
+# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
+# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
+
+name: Node.js CI
+
+on:
+ pull_request:
+
+jobs:
+ build:
+ name: Node ${{ matrix.node-version }}, Postgres ${{ matrix.postgres }}
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
+ postgres: [9, 11, 13, 15]
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
+
+ services:
+ postgres:
+ image: postgres:${{ matrix.postgres }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v2
+ with:
+ node-version: ${{ matrix.node-version }}
+
+ - name: Get yarn cache directory path
+ id: yarn-cache-dir-path
+ run: echo "::set-output name=dir::$(yarn cache dir)"
+
+ - name: Cache Yarn
+ uses: actions/cache@v2
+ id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
+ with:
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-yarn-
+
+ - name: Cache node_modules
+ uses: actions/cache@v2
+ with:
+ path: web/node_modules
+ key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
+
+ # Install dependencies
+ - run: yarn --frozen-lockfile
+ # Run Linters
+ - run: yarn lint
+ # Run Tests
+ - run: yarn test
diff --git a/.gitignore b/.gitignore
index 2932c93..bc59baf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
node_modules
.nyc_output
coverage
+.npmrc
# Mac OS
.DS_Store
diff --git a/README.md b/README.md
index 37c137c..e92a18a 100644
--- a/README.md
+++ b/README.md
@@ -1,58 +1,122 @@



-
-
+
+

-Use Node.js and databases? Want to do smart architecture decisions? Do not invent wheel, use Liquibase.
+---
+
+[][1][][2][][3][][4][][5]
+
+[1]: https://twitter.com/liquibase
+[2]: https://www.linkedin.com/company/liquibase
+[3]: https://stackoverflow.com/tags/liquibase/
+[4]: https://github.com/liquibase/liquibase
+[5]: https://www.youtube.com/channel/UC5qMsRjObu685rTBq0PJX8w
+
+
+Use Node 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.
+### Concerned About Install Size?
+For a drastically smaller version of this package, be sure to check out our [Zero-Dependency Peer-Dependency version](https://www.npmjs.com/package/liquibase/v/0.0.0). You can access this version under the tag `@pd` for `Peer Dependency`. This version of the package boasts an unpacked size of `359 kB`. Just be sure to [correctly configure your project](#peer-dependency-@pd)!
+
+## Table of Contents
+* [Installation](#installation)
+* [Sandbox](#sandbox)
+* [Usage](#usage)
+ * [CLI](#cli)
+ * [In Your Project Files](#in-your-project-files)
+* [Features](#features)
+ * [TypeScript](#typescript)
+ * [Library and CLI](#library-and-cli)
+ * [Liquibase CLI Command API Parity](#liquibase-cli-command-api-parity)
+ * [Liquibase CLI Peer Dependency](#liquibase-cli-peer-dependency-(optional))
+ * [WTR!?](#wtr!?-why-the-re-write-!?)
+* [Bundled Releases](#bundled-releases)
+ * [Bundled Version Numbers](#bundled-version-numbers)
+* [Peer Dependency (@pd)](#peer-dependency-@pd)
+* [Want to Help?](#want-to-help)
+ * [Build](#build)
+ * [Tests](#tests)
+ * [Env Vars](#env-vars)
+* [Getting More Knowledge About Liquibase](#getting-more-knowledge-about-liquibase)
+* [Liquibase CLI](#liquibase-cli)
+
+
## Installation
-There is an easy way to integrate Liquibase power to Node.js application. All you need
-is npm package.
-`$ npm install --save liquibase`
+There is an easy way to integrate Liquibase power to Node application. All you need
+is NPM package.
+
+```bash
+yarn add liquibase
+```
+
+or:
+```bash
+$ NPM install --save liquibase
+```
+
+### Sandbox
+> "If this isn't making sense, it doesn't make it lies." (Cornell, 1994).
+We have also provided a [Small Sandbox Project](https://github.com/tabuckner/node-liquibase-sandbox) where you can easily evaluate [Liquibase](https://github.com/liquibase/liquibase) and `node-liquibase` against a Postgres Database.
+
+The Sandbox project includes startup scripts, and examples to demonstrate how to use `node-liquibase` in TypeScript, JavaScript, and as a CLI tool.
## 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.
+
+This package exposes both a CLI tool and a Library to help you in your Database Migration efforts!
+
### CLI
+
You can use this NPM package as a CLI tool under the namespace `node-liquibase` if you wish.
-#### Example
-##### Bundled Liquibase Executable
+
+#### Bundled Liquibase Executable
+
```bash
node-liquibase
---changeLogFile="/examples/change-log-examples/postgreSQL/changelog.xml"
+--changeLogFile="/path/to/my/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"
+--classpath="/Users/me/path/to/my/db-drivers/postgresql-42.4.2.jar"
status
```
-##### Alternative Liquibase Executable
+#### Liquibase Executable "Peer Dependency"
+
```bash
-node-liquibase /Users/taylor/Dev/Liquibase/hackathons/node-liquibase/bin/liquibase/liquibase
- --changeLogFile="/examples/change-log-examples/postgreSQL/changelog.xml"
+node-liquibase /Users/me/path/to/my/executable/for/liquibase
+ --changeLogFile="/path/to/my/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"
+ --classpath="/Users/me/path/to/my/db-drivers/postgresql-42.4.2.jar"
status
```
### In Your Project Files
+
#### TypeScript
+
```typescript
-import { LiquibaseConfig, Liquibase, POSTGRESQL_DEFAULT_CONFIG } from 'node-liquibase'
+import {
+ LiquibaseConfig,
+ Liquibase,
+ POSTGRESQL_DEFAULT_CONFIG,
+} from '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() {
@@ -65,46 +129,192 @@ doEet();
```
#### JavaScript
-From the index.js file adjust "<>" fields accordingly:
+
```js
-const fromLibrary = require('node-liquibase/cjs/index');
-const POSTGRESQL_DEFAULT_CONFIG = require('node-liquibase/cjs/constants/defaults/postgresql-default.config').POSTGRESQL_DEFAULT_CONFIG;
+const Liquibase = require('liquibase').Liquibase;
+const POSTGRESQL_DEFAULT_CONFIG = require('liquibase').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',
+ ...POSTGRESQL_DEFAULT_CONFIG,
+ changeLogFile: './changelog.xml',
+ url: 'jdbc:postgresql://localhost:5432/node_liquibase_testing',
+ username: 'yourusername',
+ password: 'yoursecurepassword',
}
+const instTs = new Liquibase(myConfig);
-const instance = new fromLibrary.Liquibase(myConfig);
+instTs.status();
+```
-doEet();
+## Features
+### TypeScript
+#### Before
+The previous project did not have the greatest experience for TypeScript environments. In addition, one of our goals was improving the DX for JavaScript engineers as well. Luckily, a lot of popular Text Editors are improving their IntelliSense featuresets.
+#### Now
+With the new package you can will get:
+* Liquibase command documentation right at your fingertips
+* Liquibase command Parameter documentation
+* Liquibase CLI Command API Parity
-async function doEet() {
- await instance.status();
- // await instance.update();
- // await instance.dropAll();
+https://user-images.githubusercontent.com/32392635/115454680-ac49cd80-a1e6-11eb-85fa-df91caf4a7f6.mp4
+
+### Library and CLI
+In order to keep the DX as smooth as possible without deprecating the project that inspired the re-write, we've provided both an NPM package and a CLI tool. We did this by transpiling both an ES Module and a Common JS module in the dist code. The Node CLI of this package can be used with `node-liquibase`.
+
+However, when importing the modules to use them in a JavaScript or TypeScript file, be sure to import from the correct module name: `liquibase`. We are forced to keep this package name for now due to dependent projects.
+
+### Liquibase CLI Command API Parity
+We were careful to ensure that all 'top level' Liquibase commands are implemented in this package. No more magic strings!
+
+[Here's a complete listing]('./src/enums/liquibase-commands.enum.ts') of commands that have been implemented.
+
+### Liquibase CLI Peer Dependency (Optional)
+WIP
+
+## WTR!? (Why The Re-write!?)
+The original fork of this project has been left intact to give credit where credit is due. As an Organization, Liquibase can be summarized as follows: No punks, no jerks. Because of this, we cannot ignore [pablodenadai/node-liquibase](https://github.com/pablodenadai/node-liquibase). It was these efforts that ultimately led to the decision to improve on that project.
+
+### TypeScript
+At Liquibase we are avid TypeScript users, so naturally we expect the developer experience we're accustomed to out of our own packages. In order to provide the DX _we would want_, we needed to rethink how this library was implemented.
+
+Adding TypeScript support was at the core of this.
+
+### No Magic Strings!
+Magic strings, while functional, are error prone. Instead of passing a string of the command and parameters to Liquibase, we've replicated the top level Liquibase CLI API within this package.
+
+Our aim is to provide a more stable and guided API for new Liquibase users operating in a Node context.
+
+This means no more of this:
+```typescript
+liquibase.run('status');
+```
+
+and more of this:
+```typescript
+liquibase.status();
+```
+
+## Bundled Releases
+In order to make installation of Liquibase easier for people who are new to the Liquibase toolset, we've chosen to release 'bundled' versions of this project, `node-liquibase`. This means that if you are beholden to a particular version of [Liquibase Core](https://github.com/liquibase/liquibase) you will be able to install a related specific version of `node-liquibase` and have [Liquibase Core](https://github.com/liquibase/liquibase) ready at your fingertips.
+
+This makes the assumption that a consumer of `node-liquibase` _wants_ that. If this is not `true` and you prefer to make use of a more `peer dependency` type of experience, we offer a version of `node-liquibase` that **DOES NOT** bundle an associated version of [Liquibase Core](https://github.com/liquibase/liquibase).
+
+### Bundled Version Numbers
+Because [Liquibase Core](https://github.com/liquibase/liquibase) and `node-liquibase` both use a similar versioning strategy, and because NPM requires a version number bump for even the smallest change, there will not be 100% alignment between the version numbers of each project.
+
+It is safe to assume that the Major and Minor version numbers between the two projects will match on any given `npm` installation of `node-liquibase`.
+
+For example:
+* Let's assume you are required to use [Liquibase Core](https://github.com/liquibase/liquibase) `v4.3.3`
+* `node-liquibase` released `4.3.3` alongside [Liquibase Core](https://github.com/liquibase/liquibase), but needed to update documentation after the fact
+* `node-liquibase` patches its version number and releases `4.3.4`
+* As a User, you could run `yarn add liquibase@4.3` which would install the latest patch version of `4.3` in this case `4.3.4`
+* The "Bundled Liquibase" version would still be `4.3.3` but `node-liquibase` would be `4.3.4`
+
+If you wish to opt-out of the "Bundled Version" you can check out our [Peer Dependency](#peer-dependency-@pd) release.
+
+## Peer Dependency (@pd)
+### Install
+In order to use this `p[eer]-d[ependency]` version of `node-liquibase` you can install with:
+
+```bash
+yarn add liquibase@pd
+```
+
+or
+
+```bash
+npm i liquibase@pd
+```
+
+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.
+
+Additionally, we removed the bundled drivers 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.
+
+### Configuration Updates (TS or JS)
+Using the `liquibase` property on your config object.
+
+#### Before
+```typescript
+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',
}
+const inst = new Liquibase(myConfig);
+
+inst.status();
```
-## Want to help?
+#### After
+```typescript
+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)
+Using the `--liquibase` flag on your CLI command.
+
+#### Before
+```bash
+yarn node-liquibase --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
+```
+
+#### After
+```bash
+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 to see a working setup of `liquibase@pd` be sure to check out the `peer-dependency` branch of the [Node Liquibase Sandbox](https://github.com/tabuckner/node-liquibase-sandbox/blob/peer-dependency/index.ts). You can see a diff of the two approaches (Bundled v. Peer) [Here](https://github.com/tabuckner/node-liquibase-sandbox/compare/master...peer-dependency)
+
+## 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:
+
```bash
yarn build
```
### Tests
+
Run tests with:
+
```bash
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.
+
+## Getting More Knowledge About Liquibase
+
+- [Liquibase University](https://learn.liquibase.com/index)
+- [Liquibase Documentation](https://docs.liquibase.com/home.html)
+
+## Liquibase CLI
+
+[Download Liquibase CLI](https://www.liquibase.org/download)
diff --git a/docs/assets/node-liquibase.png b/docs/assets/node-liquibase.png
new file mode 100644
index 0000000..de1b7cf
Binary files /dev/null and b/docs/assets/node-liquibase.png differ
diff --git a/drivers/postgresql-42.2.8.jar b/drivers/postgresql-42.2.8.jar
deleted file mode 100644
index 2566145..0000000
Binary files a/drivers/postgresql-42.2.8.jar and /dev/null differ
diff --git a/drivers/postgresql-42.4.2.jar b/drivers/postgresql-42.4.2.jar
new file mode 100644
index 0000000..f99cd43
Binary files /dev/null and b/drivers/postgresql-42.4.2.jar differ
diff --git a/examples/change-log-examples/mssql/changelog.mssql.sql b/examples/change-log-examples/mssql/changelog.mssql.sql
deleted file mode 100644
index a10405f..0000000
--- a/examples/change-log-examples/mssql/changelog.mssql.sql
+++ /dev/null
@@ -1,4 +0,0 @@
---liquibase formatted sql
-
---changeset SteveZ:1
-CREATE TABLE CustomerDemographics (CustomerTypeID nchar(10) NOT NULL, CustomerDesc nvarchar(MAX));
diff --git a/examples/change-log-examples/mssql/changelog.xml b/examples/change-log-examples/mssql/changelog.xml
deleted file mode 100644
index 23613ff..0000000
--- a/examples/change-log-examples/mssql/changelog.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/change-log-examples/postgreSQL/changelog.postgresql.sql b/examples/change-log-examples/postgreSQL/changelog.postgresql.sql
deleted file mode 100644
index f931fca..0000000
--- a/examples/change-log-examples/postgreSQL/changelog.postgresql.sql
+++ /dev/null
@@ -1,10 +0,0 @@
---liquibase formatted sql
-
---changeset SteveZ:1
-CREATE TABLE "execSales" (id INTEGER NOT NULL, name VARCHAR(255), CONSTRAINT id_pkey PRIMARY KEY (id));
-
---changeset SteveZ:2
-CREATE VIEW "newView" AS SELECT "execSales".id,
- "execSales".name
- FROM "execSales";
-
diff --git a/examples/change-log-examples/postgreSQL/changelog.xml b/examples/change-log-examples/postgreSQL/changelog.xml
deleted file mode 100644
index 966c826..0000000
--- a/examples/change-log-examples/postgreSQL/changelog.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/liquibase_mssql.js b/examples/liquibase_mssql.js
deleted file mode 100644
index 6b02fed..0000000
--- a/examples/liquibase_mssql.js
+++ /dev/null
@@ -1,91 +0,0 @@
-const liquibase = require("../lib/index");
-// const path = require('path'); // Uncomment if needed
-
-/**
- *******************************************
- ************ COMMANDS TEMPLATE ************
- *******************************************
- */
-//const = require('../lib/index');
-
-// ({
-// contexts: ',',
-// labels: ',',
-// logLevel: '',
-// overwriteOutputFile: '',
-// logFile: ''
-// })
-// .run('', '')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-
-/**
- ******************************************
- *********** COMMANDS SAMPLES *************
- ******************************************
- */
-const config = {
- contexts: 'TEST,DEV',
- labels: 'staging,Jira-1200',
- logLevel: 'debug',
- overwriteOutputFile: 'true',
- logFile: 'myLog.log'
-};
-
-liquibase(config)
- .run('status', '--verbose')
- .then(() => console.log('success'))
- .catch((err) => console.error('fail', err));
-
-// liquibase(config)
-// .run('updateSQL')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase(config)
-// .run('update')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase({
-// referenceUrl: '"jdbc:sqlserver://localhost;database=HR_DEV;"',
-// referenceUsername: 'system',
-// referencePassword: 'password',
-// overwriteOutputFile: 'true',
-// outputFile: 'myDiff.txt',
-// logLevel: 'debug',
-// overwriteOutputFile: 'true',
-// logFile: 'myLog.log'
-// })
-// .run('diff')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase({
-// url: '"jdbc:sqlserver://localhost;database=HR_TEST;"',
-// classpath: 'drivers/mssql-jdbc-7.4.1.jre8.jar',
-// username: 'system',
-// password: 'password',
-// overwriteOutputFile: 'true',
-// outputFile: 'mySnapshot.json',
-// logLevel: 'debug',
-// logFile: 'myLog.log'
-// })
-// .run('snapshot')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase({
-// changeLogFile: 'change-log-examples/mssql/changelog.mssql.sql',
-// url: '"jdbc:sqlserver://localhost;database=HR_TEST;"',
-// classpath: 'drivers/mssql-jdbc-7.4.1.jre8.jar',
-// username: 'system',
-// password: 'password',
-// logLevel: 'debug',
-// overwriteOutputFile: 'true',
-// logFile: 'myLog.log'
-// })
-// .run('generateChangeLog')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
diff --git a/examples/liquibase_postgresql.js b/examples/liquibase_postgresql.js
deleted file mode 100644
index 0e39b4b..0000000
--- a/examples/liquibase_postgresql.js
+++ /dev/null
@@ -1,87 +0,0 @@
-const liquibase = require("../lib/index");
-const path = require('path');
-
-//*********** commands template ************
-//const = require('node-liquibase');
-
-// ({
-// contexts: ',',
-// labels: ',',
-// logLevel: '',
-// overwriteOutputFile: '',
-// logFile: ''
-// })
-// .run('', '')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-
-/**
- ******************************************
- *********** COMMANDS SAMPLES *************
- ******************************************
- */
-const config = {
- contexts: 'TEST,DEV',
- labels: 'staging,Jira-1200',
- logLevel: 'debug',
- overwriteOutputFile: 'true',
- logFile: 'myLog.log'
-};
-
-liquibase(config)
- .run('status', '--verbose')
- .then(() => console.log('success'))
- .catch((err) => console.error('fail', err));
-
-// liquibase(config)
-// .run('updateSQL')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase(config)
-// .run('update')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase({
-// referenceUrl: 'jdbc:postgresql://localhost:5432/MY_DATABASE_DEV',
-// referenceUsername: 'postgres',
-// referencePassword: 'password',
-// overwriteOutputFile: 'true',
-// outputFile: 'myDiff.txt',
-// logLevel: 'debug',
-// overwriteOutputFile: 'true',
-// logFile: 'myLog.log'
-// })
-// .run('diff')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase({
-// url: 'jdbc:postgresql://localhost:5432/MY_DATABASE_TEST',
-// classpath: 'drivers/postgresql-42.2.8.jar',
-// username: 'postgres',
-// password: 'password',
-// overwriteOutputFile: 'true',
-// outputFile: 'mySnapshot.json',
-// logLevel: 'debug',
-// logFile: 'myLog.log'
-// })
-// .run('snapshot')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
-
-// liquibase({
-// changeLogFile: 'change-log-examples/postgreSQL/my_new_changelog.postgresql.sql',
-// url: 'jdbc:postgresql://localhost:5432/MY_DATABASE_TEST',
-// classpath: 'drivers/postgresql-42.2.8.jar',
-// username: 'postgres',
-// password: 'password',
-// logLevel: 'debug',
-// overwriteOutputFile: 'true',
-// logFile: 'myLog.log'
-// })
-// .run('generateChangeLog')
-// .then(() => console.log('success'))
-// .catch((err) => console.error('fail', err));
diff --git a/examples/sandbox/implementation.js b/examples/sandbox/implementation.js
deleted file mode 100644
index adf1e09..0000000
--- a/examples/sandbox/implementation.js
+++ /dev/null
@@ -1,21 +0,0 @@
-const fromLibrary = require('../../lib/cjs/index');
-const POSTGRESQL_DEFAULT_CONFIG = require('../../lib/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();
-}
diff --git a/examples/sandbox/implementation.ts b/examples/sandbox/implementation.ts
deleted file mode 100644
index a9b28ee..0000000
--- a/examples/sandbox/implementation.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { LiquibaseConfig, Liquibase, POSTGRESQL_DEFAULT_CONFIG } from '../../lib/esm'
-
-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();
diff --git a/.travis.yml b/old.travis.yml
similarity index 80%
rename from .travis.yml
rename to old.travis.yml
index dab87c7..b2de2a2 100644
--- a/.travis.yml
+++ b/old.travis.yml
@@ -4,8 +4,8 @@ cache:
- node_modules
node_js:
- '12'
-after_script:
- - bash <(curl -s https://codecov.io/bash)
+# after_script:
+# - bash <(curl -s https://codecov.io/bash)
services:
- postgresql
script:
diff --git a/package.json b/package.json
index 600748c..cca7d54 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
- "name": "node-liquibase",
- "version": "2.0.0",
+ "name": "liquibase",
+ "version": "2.0.5",
"description": "Node.js wrapper for Liquibase",
"bin": {
"node-liquibase": "dist/cli.js"
@@ -17,13 +17,17 @@
"build:library": "tsdx build",
"build:cli": "yarn tsup ./src/cli.ts",
"test": "tsdx test",
- "test:watch": "yarn jest --watchAll",
+ "test:watch": "yarn test --watchAll",
"lint": "tsdx lint",
"copy:dependencies": "yarn copy:liquibase && yarn copy:drivers",
"copy:liquibase": "ncp ./bin/liquibase ./dist/liquibase",
"copy:drivers": "ncp ./drivers ./dist/drivers",
+ "clean": "yarn clean:dist",
+ "clean:dist": "yarn rimraf ./dist",
"semantic-release": "semantic-release",
- "tsup": "tsup"
+ "patch": "npm version patch -m \"Bump version to %s\"",
+ "tsup": "tsup",
+ "rimraf": "rimraf"
},
"engines": {
"node": ">=6.9.0"
@@ -50,24 +54,26 @@
"url": "https://github.com/liquibase/node-liquibase/issues"
},
"homepage": "https://github.com/liquibase/node-liquibase#readme",
- "peerDependencies": {},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"prettier": {
- "printWidth": 80,
+ "printWidth": 120,
"semi": true,
"singleQuote": true,
- "trailingComma": "es5"
+ "trailingComma": "es5",
+ "useTabs": false
},
"devDependencies": {
"@semantic-release/git": "^9.0.0",
"@types/jest": "^26.0.22",
+ "@types/node": "^16.11.7",
"dotenv": "^8.2.0",
"husky": "^6.0.0",
"ncp": "^2.0.0",
+ "rimraf": "^3.0.2",
"semantic-release": "^17.4.2",
"tsdx": "^0.14.1",
"tslib": "^2.2.0",
diff --git a/src/cli.ts b/src/cli.ts
index 782e38e..8c08f5e 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -1,31 +1,33 @@
#!/usr/bin/env node
+import { LiquibaseConfig } from './models';
import { LiquibaseCommands } from './enums';
import { CommandHandler, FileHelper } from './util';
-const args = process.argv.slice(2);
-const commandString = getCommandString(args);
+const commandString = getCommandString();
+new CommandHandler({} as LiquibaseConfig).spawnChildProcess(commandString);
-CommandHandler.spawnChildProcess(commandString);
+function getCommandString(): string {
+ const args = process.argv.slice(2);
+ const argsWereProvided = args?.length > 0;
+ const errorMessage =
+ 'CLI call signature does not match the expected format. Please verify you have passed required arguments and parameters.';
+ if (!argsWereProvided) {
+ throw new Error(errorMessage);
+ }
-function getCommandString(args: Array): string {
- const argsWereProvided = args?.length > 0;
- if (!argsWereProvided) {
- throw new Error('CLI call signature does not match the expected format. Please verify you have passed required arguments and parameters.');
- }
+ const firstArg = args[0];
+ const firstArgWasAKnownCommand = Object.values(LiquibaseCommands).includes(firstArg as any);
+ const firstArgWasAFlag = firstArg.substr(0, 2) === '--';
- const firstArg = args[0];
- const firstArgWasAKnownCommand = Object.values(LiquibaseCommands).includes(firstArg as any);
- const firstArgWasAFlag = firstArg.substr(0, 2) === '--';
+ /**
+ * This allows us to support a Liquibase-core-like syntax (i think?).
+ *
+ * Basically if we recognize the first arg as a command or a flag we can be relatively certain they didn't give us a filepath to an alternative liquibase executable.
+ * In that case, we provide the `'liquibase'` string to follow normal behavior.
+ */
+ if (firstArgWasAKnownCommand || firstArgWasAFlag) {
+ args.unshift(FileHelper.bundledLiquibasePath);
+ }
- /**
- * This allows us to support a Liquibase-core-like syntax (i think?).
- *
- * Basically if we recognize the first arg as a command or a flag we can be relatively certain they didn't give us a filepath to an alternative liquibase executable.
- * In that case, we provide the `'liquibase'` string to follow normal behavior.
- */
- if (firstArgWasAKnownCommand || firstArgWasAFlag) {
- args.unshift(FileHelper.bundledLiquibasePath);
- }
-
- return args.join(' ');
+ return args.join(' ');
}
diff --git a/src/constants/defaults/mssql-default.config.ts b/src/constants/defaults/mssql-default.config.ts
index a4b66c3..b497256 100644
--- a/src/constants/defaults/mssql-default.config.ts
+++ b/src/constants/defaults/mssql-default.config.ts
@@ -2,9 +2,9 @@ import { join } from 'path';
import { LiquibaseConfig } from '../../models';
export const MSSQL_DEFAULT_CONFIG: LiquibaseConfig = {
- url: 'jdbc:sqlserver://:;database=sqlserver;',
- changeLogFile: '/examples/change-log-examples/mssql/changelog.xml',
- username: 'sa',
- password: '',
- classpath: join(__dirname, '../../../drivers/mssql-jdbc-7.4.1.jre8.jar')
+ url: 'jdbc:sqlserver://:;database=sqlserver;',
+ changeLogFile: '/examples/change-log-examples/mssql/changelog.xml',
+ username: 'sa',
+ password: '',
+ classpath: join(__dirname, '../../../drivers/mssql-jdbc-7.4.1.jre8.jar'),
};
diff --git a/src/constants/defaults/postgresql-default.config.ts b/src/constants/defaults/postgresql-default.config.ts
index 2c13ba8..833db07 100644
--- a/src/constants/defaults/postgresql-default.config.ts
+++ b/src/constants/defaults/postgresql-default.config.ts
@@ -2,9 +2,9 @@ import { join } from 'path';
import { LiquibaseConfig } from '../../models';
export const POSTGRESQL_DEFAULT_CONFIG: LiquibaseConfig = {
- changeLogFile: '/node_modules/examples/change-log-examples/postgreSQL/changelog.xml',
- url: 'jdbc:postgresql://localhost:5432/postgres',
- username: 'postgres',
- password: '',
- classpath: join(__dirname, 'drivers/postgresql-42.2.8.jar')
-}
+ changeLogFile: '/node_modules/examples/change-log-examples/postgreSQL/changelog.xml',
+ url: 'jdbc:postgresql://localhost:5432/postgres',
+ username: 'postgres',
+ password: '',
+ classpath: join(__dirname, 'drivers/postgresql-42.4.2.jar'),
+};
diff --git a/src/enums/commands-with-positional-arguments.ts b/src/enums/commands-with-positional-arguments.ts
new file mode 100644
index 0000000..c8b265f
--- /dev/null
+++ b/src/enums/commands-with-positional-arguments.ts
@@ -0,0 +1,13 @@
+export enum CommandsWithPositionalArguments {
+ futureRollbackCount = 'futureRollbackCount',
+ futureRollbackFromTag = 'futureRollbackFromTag',
+ futureRollbackSQl = 'futureRollbackSQl',
+ rollback = 'rollback',
+ rollbackCount = 'rollbackCount',
+ rollbackCountSQL = 'rollbackCountSQL',
+ rollbackDate = 'rollbackDate',
+ rollbackSql = 'rollbackSql',
+ rollbackToDate = 'rollbackToDate',
+ rollbackToDateSQL = 'rollbackToDateSQL',
+ tag = 'tag',
+}
diff --git a/src/enums/index.ts b/src/enums/index.ts
index c5cc45c..5bcb0b5 100644
--- a/src/enums/index.ts
+++ b/src/enums/index.ts
@@ -1 +1,2 @@
export * from './liquibase-commands.enum';
+export * from './liquibase-log-levels.enum';
diff --git a/src/enums/liquibase-log-levels.enum.ts b/src/enums/liquibase-log-levels.enum.ts
new file mode 100644
index 0000000..c1c21fa
--- /dev/null
+++ b/src/enums/liquibase-log-levels.enum.ts
@@ -0,0 +1,7 @@
+export enum LiquibaseLogLevels {
+ Off = 'off',
+ Severe = 'severe',
+ Warning = 'warning',
+ Info = 'info',
+ Debug = 'debug',
+}
diff --git a/src/index.ts b/src/index.ts
index 51c130e..d6e2f24 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,6 +1,6 @@
export * from './liquibase';
// export * from './cli'; // TODO: Should this be commented??
export * from './models';
-export * from './constants'
+export * from './constants';
export * from './enums';
export * from './util';
diff --git a/src/liquibase.spec.ts b/src/liquibase.spec.ts
index 2fb68c2..8a7cda8 100644
--- a/src/liquibase.spec.ts
+++ b/src/liquibase.spec.ts
@@ -1,478 +1,484 @@
-require('dotenv').config();
import {
- CalculateCheckSumCommandAttributes,
- ChangelogSyncToTagCommandAttributes,
- ChangelogSyncToTagSQLCommandAttributes,
- DbDocCommandAttributes,
- DiffChangelogCommandAttributes,
- DiffCommandAttributes,
- FutureRollbackCountSQLCommandAttributes,
- GenerateChangeLogCommandAttributes,
- Liquibase,
- RollbackCommandAttributes,
- RollbackCountCommandAttributes,
- RollbackCountSQLCommandAttributes,
- RollbackSQLCommandAttributes,
- RollbackToDateCommandAttributes,
- RollbackToDateSQLCommandAttributes,
- SnapshotCommandAttributes,
- SnapshotReferenceCommandAttributes,
- SyncHubCommandAttributes,
- TagCommandAttributes,
- TagExistsCommandAttributes,
- UpdateCommandAttributes,
- UpdateCountCommandAttributes,
- UpdateCountSQLCommandAttributes,
- UpdateSQLCommandAttributes,
- UpdateToTagCommandAttributes,
- UpdateToTagSQLCommandAttributes
+ CalculateCheckSumCommandAttributes,
+ ChangelogSyncToTagCommandAttributes,
+ ChangelogSyncToTagSQLCommandAttributes,
+ DbDocCommandAttributes,
+ DiffChangelogCommandAttributes,
+ DiffCommandAttributes,
+ FutureRollbackCountSQLCommandAttributes,
+ GenerateChangeLogCommandAttributes,
+ Liquibase,
+ RollbackCommandAttributes,
+ RollbackCountCommandAttributes,
+ RollbackCountSQLCommandAttributes,
+ RollbackSQLCommandAttributes,
+ RollbackToDateCommandAttributes,
+ RollbackToDateSQLCommandAttributes,
+ SnapshotCommandAttributes,
+ SnapshotReferenceCommandAttributes,
+ SyncHubCommandAttributes,
+ TagCommandAttributes,
+ TagExistsCommandAttributes,
+ UpdateCommandAttributes,
+ UpdateCountCommandAttributes,
+ UpdateCountSQLCommandAttributes,
+ UpdateSQLCommandAttributes,
+ UpdateToTagCommandAttributes,
+ UpdateToTagSQLCommandAttributes,
} from './index';
import { LiquibaseConfig } from './models/index';
import { POSTGRESQL_DEFAULT_CONFIG } from './constants/defaults/postgresql-default.config';
import { join } from 'path';
+import { LiquibaseCommands } from './enums';
+require('dotenv').config();
describe('Liquibase', () => {
-
- let config: LiquibaseConfig;
- let instance: Liquibase;
-
- const validPostgresConfig: LiquibaseConfig = {
- ...POSTGRESQL_DEFAULT_CONFIG,
- changeLogFile: './examples/change-log-examples/postgreSQL/changelog.xml',
- classpath: join(__dirname, '../drivers/postgresql-42.2.8.jar'),
- username: 'yourusername',
- password: 'yoursecurepassword',
- };
-
- beforeEach(() => {
- config = {
- ...validPostgresConfig,
- classpath: undefined as any,
- };
- instance = new Liquibase(config);
- })
-
- describe('#constructor', () => {
- it('should create an instance', () => {
- expect(instance).toBeInstanceOf(Liquibase);
- });
- });
-
- describe('#status', () => {
- it('should succeed', async (done) => {
- const instance = new Liquibase(validPostgresConfig);
- const test = await instance.status();
- expect(test).toBeTruthy();
- done();
- });
-
- it('should fail', async (done) => {
- expect(instance).toBeDefined();
- await expect(instance.status()).rejects.toThrow();
- done();
- });
- });
-
- describe('#update', () => {
- it('should call run method', async () => {
- const param = {} as UpdateCommandAttributes;
- spyOn(instance, 'run');
-
- instance.update(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#updateSQL', () => {
- it('should call run method', async () => {
- const param = {} as UpdateSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.updateSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#updateCount', () => {
- it('should call run method', async () => {
- const param = {} as UpdateCountCommandAttributes;
- spyOn(instance, 'run');
-
- instance.updateCount(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#updateCountSQL', () => {
- it('should call run method', async () => {
- const param = {} as UpdateCountSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.updateCountSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#updateTestingRollback', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.updateTestingRollback();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#updateToTag', () => {
- it('should call run method', async () => {
- const param = {} as UpdateToTagCommandAttributes;
- spyOn(instance, 'run');
-
- instance.updateToTag(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#updateToTagSQL', () => {
- it('should call run method', async () => {
- const param = {} as UpdateToTagSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.updateToTagSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#validate', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.validate();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#calculateCheckSum', () => {
- it('should call run method', async () => {
- const param = {} as CalculateCheckSumCommandAttributes;
- spyOn(instance, 'run');
-
- instance.calculateCheckSum(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#changelogSync', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.changelogSync();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#changelogSyncSQL', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.changelogSyncSQL();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#changelogSyncToTag', () => {
- it('should call run method', async () => {
- const param = {} as ChangelogSyncToTagCommandAttributes;
- spyOn(instance, 'run');
-
- instance.changelogSyncToTag(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#changelogSyncToTagSQL', () => {
- it('should call run method', async () => {
- const param = {} as ChangelogSyncToTagSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.changelogSyncToTagSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#clearCheckSums', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.clearCheckSums();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#dbDoc', () => {
- it('should call run method', async () => {
- const param = {} as DbDocCommandAttributes;
- spyOn(instance, 'run');
-
- instance.dbDoc(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#deactivateChangeLog', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.deactivateChangeLog();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#diff', () => {
- it('should call run method', async () => {
- const param = {} as DiffCommandAttributes;
- spyOn(instance, 'run');
-
- instance.diff(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#diffChangeLog', () => {
- it('should call run method', async () => {
- const param = {} as DiffChangelogCommandAttributes;
- spyOn(instance, 'run');
-
- instance.diffChangelog(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#dropAll', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.dropAll();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#futureRollbackSQL', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.futureRollbackSQL();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#futureRollbackCountSQL', () => {
- it('should call run method', async () => {
- const param = {} as FutureRollbackCountSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.futureRollbackCountSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#generateChangeLog', () => {
- it('should call run method', async () => {
- const param = {} as GenerateChangeLogCommandAttributes;
- spyOn(instance, 'run');
-
- instance.generateChangeLog(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#help', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.help();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#history', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.history();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#listLocks', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.listLocks();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#markNextChangeSetRan', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.markNextChangeSetRan();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#markNextChangeSetRanSQL', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.markNextChangeSetRanSQL();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#registerChangeLog', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.registerChangeLog();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#releaseLocks', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.releaseLocks();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#rollback', () => {
- it('should call run method', async () => {
- const param = {} as RollbackCommandAttributes;
- spyOn(instance, 'run');
-
- instance.rollback(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#rollbackSQL', () => {
- it('should call run method', async () => {
- const param = {} as RollbackSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.rollbackSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#rollbackCount', () => {
- it('should call run method', async () => {
- const param = {} as RollbackCountCommandAttributes;
- spyOn(instance, 'run');
-
- instance.rollbackCount(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#rollbackCountSQL', () => {
- it('should call run method', async () => {
- const param = {} as RollbackCountSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.rollbackCountSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#rollbackToDate', () => {
- it('should call run method', async () => {
- const param = {} as RollbackToDateCommandAttributes;
- spyOn(instance, 'run');
-
- instance.rollbackToDate(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#rollbackToDateSQL', () => {
- it('should call run method', async () => {
- const param = {} as RollbackToDateSQLCommandAttributes;
- spyOn(instance, 'run');
-
- instance.rollbackToDateSQL(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#snapshot', () => {
- it('should call run method', async () => {
- const param = {} as SnapshotCommandAttributes;
- spyOn(instance, 'run');
-
- instance.snapshot(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#snapshotReference', () => {
- it('should call run method', async () => {
- const param = {} as SnapshotReferenceCommandAttributes;
- spyOn(instance, 'run');
-
- instance.snapshotReference(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#status', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.status();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#syncHub', () => {
- it('should call run method', async () => {
- const param = {} as SyncHubCommandAttributes;
- spyOn(instance, 'run');
-
- instance.syncHub(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#tag', () => {
- it('should call run method', async () => {
- const param = {} as TagCommandAttributes;
- spyOn(instance, 'run');
-
- instance.tag(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#tagExists', () => {
- it('should call run method', async () => {
- const param = {} as TagExistsCommandAttributes;
- spyOn(instance, 'run');
-
- instance.tagExists(param);
- expect(instance['run']).toHaveBeenCalled();
- });
- });
-
- describe('#unexpectedChangeSets', () => {
- it('should call run method', async () => {
- spyOn(instance, 'run');
-
- instance.unexpectedChangeSets();
- expect(instance['run']).toHaveBeenCalled();
- });
- });
+ let config: LiquibaseConfig;
+ let instance: Liquibase;
+
+ const validPostgresConfig: LiquibaseConfig = {
+ ...POSTGRESQL_DEFAULT_CONFIG,
+ changeLogFile: './examples/change-log-examples/postgreSQL/changelog.xml',
+ classpath: join(__dirname, '../drivers/postgresql-42.4.2.jar'),
+ username: 'yourusername',
+ password: 'yoursecurepassword',
+ };
+
+ beforeEach(() => {
+ config = {
+ ...validPostgresConfig,
+ classpath: undefined as any,
+ };
+ instance = new Liquibase(config);
+ });
+
+ describe('#constructor', () => {
+ it('should create an instance', () => {
+ expect(instance).toBeInstanceOf(Liquibase);
+ });
+ });
+
+ describe('#status', () => {
+ it('should call run method', async () => {
+ const param = {} as UpdateCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.update(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#update', () => {
+ it('should call run method', async () => {
+ const param = {} as UpdateCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.update(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#updateSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as UpdateSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.updateSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#updateCount', () => {
+ it('should call run method', async () => {
+ const param = {} as UpdateCountCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.updateCount(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#updateCountSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as UpdateCountSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.updateCountSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#updateTestingRollback', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.updateTestingRollback();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#updateToTag', () => {
+ it('should call run method', async () => {
+ const param = {} as UpdateToTagCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.updateToTag(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#updateToTagSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as UpdateToTagSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.updateToTagSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#validate', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.validate();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#calculateCheckSum', () => {
+ it('should call run method', async () => {
+ const param = {} as CalculateCheckSumCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.calculateCheckSum(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#changelogSync', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.changelogSync();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#changelogSyncSQL', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.changelogSyncSQL();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#changelogSyncToTag', () => {
+ it('should call run method', async () => {
+ const param = {} as ChangelogSyncToTagCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.changelogSyncToTag(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#changelogSyncToTagSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as ChangelogSyncToTagSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.changelogSyncToTagSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#clearCheckSums', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.clearCheckSums();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#dbDoc', () => {
+ it('should call run method', async () => {
+ const param = {} as DbDocCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.dbDoc(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#deactivateChangeLog', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.deactivateChangeLog();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#diff', () => {
+ it('should call run method', async () => {
+ const param = {} as DiffCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.diff(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#diffChangeLog', () => {
+ it('should call run method', async () => {
+ const param = {} as DiffChangelogCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.diffChangelog(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#dropAll', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.dropAll();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#futureRollbackSQL', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.futureRollbackSQL();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#futureRollbackCountSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as FutureRollbackCountSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.futureRollbackCountSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#generateChangeLog', () => {
+ it('should call run method', async () => {
+ const param = {} as GenerateChangeLogCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.generateChangeLog(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#help', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.help();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#history', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.history();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#listLocks', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.listLocks();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#markNextChangeSetRan', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.markNextChangeSetRan();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#markNextChangeSetRanSQL', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.markNextChangeSetRanSQL();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#registerChangeLog', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.registerChangeLog();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#releaseLocks', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.releaseLocks();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#rollback', () => {
+ it('should call run method', async () => {
+ const param = {} as RollbackCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.rollback(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#rollbackSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as RollbackSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.rollbackSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#rollbackCount', () => {
+ it('should call run method', async () => {
+ const param = {} as RollbackCountCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.rollbackCount(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#rollbackCountSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as RollbackCountSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.rollbackCountSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#rollbackToDate', () => {
+ it('should call run method', async () => {
+ const param = {} as RollbackToDateCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.rollbackToDate(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#rollbackToDateSQL', () => {
+ it('should call run method', async () => {
+ const param = {} as RollbackToDateSQLCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.rollbackToDateSQL(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#snapshot', () => {
+ it('should call run method', async () => {
+ const param = {} as SnapshotCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.snapshot(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#snapshotReference', () => {
+ it('should call run method', async () => {
+ const param = {} as SnapshotReferenceCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.snapshotReference(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#status', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.status();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#syncHub', () => {
+ it('should call run method', async () => {
+ const param = {} as SyncHubCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.syncHub(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#tag', () => {
+ it('should call run method', async () => {
+ const param = {} as TagCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.tag(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#tagExists', () => {
+ it('should call run method', async () => {
+ const param = {} as TagExistsCommandAttributes;
+ spyOn(instance, 'run');
+
+ instance.tagExists(param);
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#unexpectedChangeSets', () => {
+ it('should call run method', async () => {
+ spyOn(instance, 'run');
+
+ instance.unexpectedChangeSets();
+ expect(instance['run']).toHaveBeenCalled();
+ });
+ });
+
+ describe('#run', () => {
+ it('should delegate to #spawnChildProcess', async done => {
+ spyOn(instance, 'spawnChildProcess');
+ const mockAction = LiquibaseCommands.Status;
+ const mockParams = undefined;
+ await instance['run'](mockAction, mockParams);
+ expect(instance['spawnChildProcess']).toHaveBeenCalledWith(expect.stringContaining('status'));
+ done();
+ });
+ });
});
diff --git a/src/liquibase.ts b/src/liquibase.ts
index 55a4e60..f46c122 100644
--- a/src/liquibase.ts
+++ b/src/liquibase.ts
@@ -4,806 +4,817 @@ import { CommandHandler, FileHelper } from './util';
import { POSTGRESQL_DEFAULT_CONFIG } from './constants/defaults/postgresql-default.config';
import { LiquibaseCommands } from './enums/liquibase-commands.enum';
import {
- LiquibaseConfig,
- CalculateCheckSumCommandAttributes,
- UpdateCommandAttributes,
- RollbackCommandAttributes,
- RollbackSQLCommandAttributes,
- RollbackCountCommandAttributes,
- RollbackCountSQLCommandAttributes,
- RollbackToDateCommandAttributes,
- RollbackToDateSQLCommandAttributes,
- SnapshotCommandAttributes,
- SnapshotReferenceCommandAttributes,
- SyncHubCommandAttributes,
- TagCommandAttributes,
- TagExistsCommandAttributes,
- FutureRollbackCountSQLCommandAttributes,
- GenerateChangeLogCommandAttributes,
- UpdateSQLCommandAttributes,
- UpdateCountCommandAttributes,
- UpdateCountSQLCommandAttributes,
- UpdateToTagCommandAttributes,
- UpdateToTagSQLCommandAttributes,
- ChangelogSyncToTagCommandAttributes,
- ChangelogSyncToTagSQLCommandAttributes,
- DbDocCommandAttributes,
- DiffChangelogCommandAttributes,
- DiffCommandAttributes,
-} from './models/index';
-
+ LiquibaseConfig,
+ CalculateCheckSumCommandAttributes,
+ UpdateCommandAttributes,
+ RollbackCommandAttributes,
+ RollbackSQLCommandAttributes,
+ RollbackCountCommandAttributes,
+ RollbackCountSQLCommandAttributes,
+ RollbackToDateCommandAttributes,
+ RollbackToDateSQLCommandAttributes,
+ SnapshotCommandAttributes,
+ SnapshotReferenceCommandAttributes,
+ SyncHubCommandAttributes,
+ TagCommandAttributes,
+ TagExistsCommandAttributes,
+ FutureRollbackCountSQLCommandAttributes,
+ GenerateChangeLogCommandAttributes,
+ UpdateSQLCommandAttributes,
+ UpdateCountCommandAttributes,
+ UpdateCountSQLCommandAttributes,
+ UpdateToTagCommandAttributes,
+ UpdateToTagSQLCommandAttributes,
+ ChangelogSyncToTagCommandAttributes,
+ ChangelogSyncToTagSQLCommandAttributes,
+ DbDocCommandAttributes,
+ DiffChangelogCommandAttributes,
+ DiffCommandAttributes,
+} from './models';
+import { CommandsWithPositionalArguments } from './enums/commands-with-positional-arguments';
+import { ParamsModel, WithOptionalSubstitutionParams } from './models/commands/substitution-params.model';
export class Liquibase {
- /**
- * @description Returns an instance of a lightweight Liquibase Wrapper.
- *
- * @param params Configuration for an instance of `Liquibase`
- *
- * * @example
- * ```javascript
- * const liquibase = require('node-liquibase');
- *
- * const config = {
- * contexts: 'TEST,DEV',
- * labels: 'staging,Jira-1200',
- * logLevel: 'debug',
- * overwriteOutputFile: 'true',
- * logFile: 'myLog.log'
- * };
- *
- * liquibase(config)
- * .run('status', '--verbose')
- * .then(() => console.log('success'))
- * .catch((err) => console.error('fail', err));
- * ```
- */
- constructor(
- private params: LiquibaseConfig,
- ) {
- this.mergeParamsWithDefaults(params);
- }
-
- /**
- * The `update` command deploys any changes that are in the changelog file and that have not been deployed to your database yet.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `update` command is typically used to apply database changes that are specified in the changelog file to your database.
- * When you run the `update` command, Liquibase sequentially reads changesets in the changelog file, then it compares the unique identifiers of id, author, and path to filename to the values stored in the DATABASECHANGELOG table.
- * - If the unique identifiers do not exist, Liquibase will apply the changeset to the database
- * - If the unique identifiers exist, the MD5Sum of the changeset is compared to the one in the database
- * - If they are different, Liquibase will produce an error message that someone has changed it unexpectedly. However, if the status of the runOnChange or runAlways changeset attribute is set to TRUE, Liquibase will re-apply the changeset
- *
- * {@link https://docs.liquibase.com/commands/community/update.html Documentation}
- */
- public update(params: UpdateCommandAttributes) {
- this.run(LiquibaseCommands.Update, params);
- return this;
- }
-
- /**
- * The `updateSQL` command is a helper command that allows you to inspect the SQL Liquibase will run while using the `update` command.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `updateSQL` command is used when you want to inspect the raw SQL before running the `update` command, so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to apply database changes you have added to the changelog file.
- *
- * {@link https://docs.liquibase.com/commands/community/updatesql.html Documentation}
- */
- public updateSQL(params: UpdateSQLCommandAttributes) {
- this.run(LiquibaseCommands.UpdateSql, params);
- return this;
- }
-
- /**
- * The `updateCount ` command updates a specified number of changesets, where is the number of changesets you want to update sequentially on your database.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `updateCount ` command is mainly used when you want to apply changes and update changesets sequentially, starting with the changesets from the top of the changelog file until the number specified is reached.
- *
- * {@link https://docs.liquibase.com/commands/community/updatecount.html Documentation}
- */
- public updateCount(params: UpdateCountCommandAttributes) {
- this.run(LiquibaseCommands.UpdateCount, params);
- return this;
- }
-
- /**
- * The `updateCountSQL ` command is a helper command that inspects the SQL Liquibase will run while using the `updateCount ` command.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `updateCountSQL ` command is used to inspect the raw SQL before running the `updateCount ` command, so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to apply a specified number of database changes you have added to the changelog file.
- *
- * {@link https://docs.liquibase.com/commands/community/updatecountsql.html Documentation}
- */
- public updateCountSQL(params: UpdateCountSQLCommandAttributes) {
- this.run(LiquibaseCommands.UpdateCountSql, params);
- return this;
- }
-
- /**
- * `updateTestingRollback` tests rollback support by deploying all pending changesets to the database, executes a rollback sequentially for the equal number of changesets that were deployed, and then runs the update again deploying all changesets to the database.
- *
- * @description `updateTestingRollback` is typically used when you want to test rollback functionality when deploying changesets in your changelog sequentially. Run `updateTestingRollback` only when all pending changelogs have been verified as ready to be deployed as you cannot specify changesets to exclude.
- * `updateTestingRollback` utilizes a multi-step operation and runs in sequential order:
- * - update changeset1; update changeset2; update changeset3
- * - rollback changeset3; rollback changeset2; rollback changeset1
- * - update changeset1; update changeset2 update changeset3
- *
- * {@link https://docs.liquibase.com/commands/community/updatetestingrollback.html Documentation}
- */
- public updateTestingRollback() {
- this.run(LiquibaseCommands.UpdateTestingRollback);
- return this;
- }
-
- /**
- * The `updateToTag ` command applies sequential changes to your database from the newest changeset to the changeset with the tag you specified and applied earlier.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `updateToTag ` command is mainly used to apply changes sequentially, starting with the changesets from the top of the changelog file until the specified tag is reached. Even though there are other undeployed changes in the changelog, the command deploys only the changesets associated with a specific tag.
- *
- * {@link https://docs.liquibase.com/commands/community/updatetotag.html Documentation}
- */
- public updateToTag(params: UpdateToTagCommandAttributes) {
- this.run(LiquibaseCommands.UpdateToTag, params);
- return this;
- }
-
- /**
- * The `updateToTagSQL ` command is a helper command that inspects the SQL Liquibase will run while using the `updateToTag ` command.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `updateToTagSQL ` command is used to inspect the raw SQL before running the `updateToTag ` command, so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to apply database changes you have added to the changelog file based on the tag specified.
- *
- * {@link https://docs.liquibase.com/commands/community/updatetotagsql.html Documentation}
- */
- public updateToTagSQL(params: UpdateToTagSQLCommandAttributes) {
- this.run(LiquibaseCommands.UpdateToTagSql, params);
- return this;
- }
-
- /**
- * The `validate` command checks and identifies any possible errors in a changelog that can cause the `update` command to fail.
- *
- * @description The `validate` command is mainly used when you want to detect if there are any issues with a changelog before running the `update` command.
- * With the help of the `validate` command, you can avoid a partial update, where only some changesets are applied due to an error in your changelog file.
- * Use the validate command to ensure that:
- * - The XML/YAML/JSON/formatted SQL is structured correctly
- * - Referenced files can be found
- * - There are no duplicated id/author/file combinations
- * - There aren't any checksum errors
- * - Any required or not allowed attributes are correct for your database
- *
- * {@link https://docs.liquibase.com/commands/community/validate.html Documentation}
- */
- public validate() {
- this.run(LiquibaseCommands.Validate);
- return this;
- }
-
- /**
- * The `calculateCheckSum ` command calculates and prints a checksum for the changeset with the specified id in the following format: filepath::id::author.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `calculateCheckSum ` command is typically used to compute an MD5 checksum, which serves as a unique identifier for the changeset. As a result, you can see whether the changeset has been changed and whether it has to be deployed differently now.
- * When running the `calculateCheckSum ` command, the DATABASECHANGELOG table calculates an MD5 checksum for each entry based on the SQL script of the changeset. This checksum helps Liquibase detect differences between the changesets you want to deploy and the changesets that have already been run against the database.
- * The MD5SUM column in the DATABASECHANGELOG table contains a checksum of the changeset and any change made in the changeset will result in a different checksum.
- *
- * {@link https://docs.liquibase.com/commands/community/calculatechecksum.html Documentation}
- */
- public calculateCheckSum(params: CalculateCheckSumCommandAttributes) {
- this.run(LiquibaseCommands.CalculateCheckSum, params);
- return this;
- }
-
- /**
- * The `rollback ` command rolls back changes made to the database based on the specified tag.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `rollback ` command is typically used to revert all changes that were made to the database after the tag you specify.
- * When you run `rollback `, Liquibase will roll back sequentially all the deployed changes until it reaches the tag row in the DATABASECHANGELOG table.
- * For example, you can use the `rollback ` command when you want to undo a series of changes made to your database related to a specific tag such as a numbered release.
- * If you have tags for release 1, release 2, and release 3, and need to make a correction in release 2, the `rollback ` command will rollback release 3 first.
- *
- * {@link https://docs.liquibase.com/commands/community/rollbackbytag.html Documentation}
- */
- public rollback(params: RollbackCommandAttributes) {
- this.run(LiquibaseCommands.Rollback, params);
- return this;
- }
-
- /**
- * The `rollbackSQL ` is a helper command that produces the raw SQL Liquibase would run when using the rollback command.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `rollbackSQL ` command is typically used to inspect the SQL Liquibase uses to revert changes associated with a tag you specify when you run the `rollback ` command.
- * It is best practice to use the `rollbackSQL ` command before running the `rollback ` command to ensure that you eliminate any potential risks.
- *
- * {@link https://docs.liquibase.com/commands/community/rollbacksqltag.html Documentation}
- */
- public rollbackSQL(params: RollbackSQLCommandAttributes) {
- this.run(LiquibaseCommands.RollbackSql, params);
- return this;
- }
-
- /**
- * The `rollbackCount ` command reverts a specified number of changesets, where is the number of changesets you want to revert sequentially on your database.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `rollbackCount ` command is used when you want to roll back changes sequentially,
- * starting with the most recent changes and working backward until the value specified is reached.
- *
- * {@link https://docs.liquibase.com/commands/community/rollbackcount.html Documentation}
- */
- public rollbackCount(params: RollbackCountCommandAttributes) {
- this.run(LiquibaseCommands.RollbackCount, params);
- return this;
- }
-
- /**
- * The `rollbackCountSQL ` command is a helper command that allows you to inspect the SQL Liquibase will run while using the `rollbackCount ` command.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `rollbackCountSQL ` command is used when you want to inspect the raw SQL before running the `rollbackCount ` command,
- * so you can correct any issues that may arise before running the command.
- * Liquibase uses the raw SQL to revert any changesets between the most recent and the value you specified.
- *
- * {@link https://docs.liquibase.com/commands/community/rollbackcountsql.html Documentation}
- */
- public rollbackCountSQL(params: RollbackCountSQLCommandAttributes) {
- this.run(LiquibaseCommands.RollbackCountSql, params);
- return this;
- }
-
- /**
- * The `rollbackToDate` command reverts your database to the state it was in at the date and time you specify.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `rollbackToDate` command is mainly used when you want to revert all changes made to your database from today's date to the date and time you specify.
- * The `rollbackToDate` command reverts those changesets to their previous state and allows you to target the date and time without impacting changes or deployments that came before the date and time you specified.
- *
- * {@link https://docs.liquibase.com/commands/community/rollbacktodate.html Documentation}
- */
- public rollbackToDate(params: RollbackToDateCommandAttributes) {
- this.run(LiquibaseCommands.RollbackToDate, params);
- return this;
- }
-
- /**
- * The `rollbackToDateSQL` command is a helper command that allows you to inspect the SQL Liquibase will run while using the rollbackToDate command.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `rollbackToDateSQL` command is typically used when you want to inspect the raw SQL before running the rollbackToDate command,
- * so you can correct any issues that may arise before running the command.
- *
- * {@link https://docs.liquibase.com/commands/community/rollbacktodatesql.html Documentation}
- */
- public rollbackToDateSQL(params: RollbackToDateSQLCommandAttributes) {
- this.run(LiquibaseCommands.RollbackToDateSql, params);
- return this;
- }
-
- /**
- * The `snapshot` command captures the current state of the URL database, which is the target database.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `snapshot` command is typically used when you want to see changes in your target database or keep a record of your current database state.
- * The `snapshot` command has two modes:
- * - When run without options, it gathers the current state of the database and shows a text-based version of the schema to STDOUT.
- * - When run with the --snapshotFormat=JSON option, it creates a JSON file that represents the current state of the URL database.
- * Alternatively, you can have a YAML-based output by using the --snapshotFormat=yaml attribute.
- *
- * {@link https://docs.liquibase.com/commands/community/snapshot.html Documentation}
- */
- public snapshot(params: SnapshotCommandAttributes) {
- this.run(LiquibaseCommands.Snapshot, params);
- return this;
- }
-
- /**
- * The `snapshotReference` command captures the current state of the referenceURL database, which is the source database.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `snapshotReference` command is typically used when you want to see changes in your source database or keep a record of your current database state.
- * The snapshot command has two modes:
- * - When run without options, it gathers the current state of the database and shows a text-based version of the schema to STDOUT.
- * - When run with the --snapshotFormat=JSON option, it creates a JSON file that represents the current state of the referenceURL database.
- * Alternatively, you can have a YAML-based output by using the --snapshotFormat=yaml attribute.
- *
- * {@link https://docs.liquibase.com/commands/community/snapshotreference.html Documentation}
- */
- public snapshotReference(params: SnapshotReferenceCommandAttributes) {
- this.run(LiquibaseCommands.SnapshotReference, params);
- return this;
- }
-
- /**
- * The `status --verbose` command produces a list of pending changesets with additional information that includes the id, author, and file path name.
- * The `status --verbose` command does not modify the database.
- *
- * @description The `status --verbose` command is typically used when changesets were added to a changelog through source control by another developer.
- * The command confirms what has been deployed and what changesets are pending per author and corresponding ids.
- *
- * {@link https://docs.liquibase.com/commands/community/status-verbose.html Documentation}
- */
- public status() {
- this.run(LiquibaseCommands.Status);
- return this;
- }
-
- /**
- * The `syncHub` command synchronizes the local DATABASECHANGELOG table with Liquibase Hub.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `syncHub` command is typically used when you want to:
- * - Ensure that Liquibase Hub shows the latest results from your DATABASECHANGELOG table.
- * - Synchronize the DATABASECHANGELOG table of a new project that has pre-existing data in the DATABASECHANGELOG table.
- * - Synchronize your local data if update, rollback, changelogSync, or dropAll were run while Liquibase Hub was offline.
- * When you run the `syncHub` command, you will not see any operations added to the Project associated with your changelog.
- * syncHub cannot associate previous Liquibase operations, so you will not see any operations in Liquibase Hub.
- * You will only see changesets added to the changesets tab in your Liquibase Hub project.
- *
- * {@link https://docs.liquibase.com/commands/community/synchub.html Documentation}
- */
- public syncHub(params: SyncHubCommandAttributes) {
- this.run(LiquibaseCommands.SyncHub, params);
- return this;
- }
-
- /**
- * The `tag ` command marks the current database state so you can roll back changes in the future.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `tag ` command is typically used to mark the current database state, version, release, or any other information by adding the tag to the last row in the DATABASECHANGELOG table.
- * After setting the tag, you can use the `rollback ` command to roll back all changes under this tag.
- *
- * {@link https://docs.liquibase.com/commands/community/tag.html Documentation}
- */
- public tag(params: TagCommandAttributes) {
- this.run(LiquibaseCommands.Tag, params);
- return this;
- }
-
- /**
- * The `tagExists ` command checks whether the tag you specify already exists in your database.
- *
- * @param params - Arguments/Attribute for the command.
- *
- * @description The `tagExists ` command is typically used to identify whether the specified tag exists in the database or specifically in the DATABASECHANGELOG table.
- * Running the `tagExists ` command checks for the tag and, based on whether it exists or not, provides the appropriate output.
- *
- * {@link https://docs.liquibase.com/commands/community/tagexists.html Documentation}
- */
- public tagExists(params: TagExistsCommandAttributes) {
- this.run(LiquibaseCommands.TagExists, params);
- return this;
- }
-
- /**
- * The `unexpectedChangeSets` command produces a list of changesets that were run in the database but do not exist in the current changelog.
- *
- * @description The `unexpectedChangeSets` command is typically used to detect and compare the changes between the DATABASECHANGELOG table and the current changelog.
- * If any of the changesets in the DATABASECHANGELOG table do not exist in the current changelog, the `unexpectedChangeSets` command will detect those changesets and produce them in your output.
- * The `unexpectedChangeSets` command also produces all the changesets that were previously deployed and deleted from your current changelog.
- *
- * {@link https://docs.liquibase.com/commands/community/unexpectedchangesets.html Documentation}
- */
- public unexpectedChangeSets() {
- this.run(LiquibaseCommands.UnexpectedChangeSets);
- return this;
- }
-
- /**
- * `dropAll` drops all database objects owned by the user. `dropAll` will not drop functions, procedures, or packages for the community version of Liquibase. Functions, procedures, packages, and synonyms can only be dropped for Liquibase Pro supported objects.
- *
- * @description `dropAll` is typically used when there is a need to prepare an environment schema to be identical to another environment schema. `dropAll` is useful in the developer and test environments to remove unwanted objects to reset the database to “empty”.
- * The command makes it easier to standardize another schema, compared to manually deleting the objects, or dropping and recreating the desired schema.
- * `dropAll` should not be used in a production environment to prevent removal of required objects.
- *
- * {@link https://docs.liquibase.com/commands/community/dropall.html Documentation}
- */
- public dropAll() {
- this.run(LiquibaseCommands.DropAll);
- return this;
- }
-
- /**
- * The `futureRollbackSQL` command is a helper command that produces the raw SQL Liquibase would need to roll back changes that have not yet been deployed to your database.
- *
- * @description You can use the `futureRollbackSQL` command to inspect the raw SQL Liquibase would use to revert changes associated with undeployed changesets.
- * It is best practice to inspect SQL Liquibase would run when using the `update` command so you can review any changes the command would make to your database.
- *
- * {@link https://docs.liquibase.com/commands/community/futurerollbacksql.html Documentation}
- */
- public futureRollbackSQL() {
- this.run(LiquibaseCommands.FutureRollbackSql);
- return this;
- }
-
- /**
- * The `futureRollbackCountSQL ` command generates the SQL that Liquibase would use to sequentially revert the number of changes associated with undeployed changesets, which are added to a changelog file.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `futureRollbackCountSQL ` command is typically used to inspect the SQL before rolling back the number of changesets that you have not deployed to your database but added to your changelog. The command shows the output starting with the most recent changes until the value specified is reached.
- * It is best practice to inspect SQL, which Liquibase would run when using the rollback command so you can review any changes the command would make to your database.
- *
- * {@link https://docs.liquibase.com/commands/community/futurerollbackcountsql.html Documentation}
- */
- public futureRollbackCountSQL(params: FutureRollbackCountSQLCommandAttributes) {
- this.run(LiquibaseCommands.FutureRollbackCountSql, params);
- return this;
- }
-
- /**
- * The `generateChangeLog` command creates a changelog file that has a sequence of changesets which describe how to re-create the current state of the database.
- *
- * @param params Arguments/Attributes for the command
- *
- * @description The `generateChangeLog` command is typically used when you want to capture the current state of a database, then apply those changes to any number of databases. This is typically only done when a project has an existing database, but hasn't used Liquibase before.
- * See {@link https://docs.liquibase.com/workflows/liquibase-community/existing-project.html How to set up Liquibase with an Existing Project and Multiple Environments} for more details.
- *
- * {@link https://docs.liquibase.com/commands/community/generatechangelog.html Documentation}
- */
- public generateChangeLog(params: GenerateChangeLogCommandAttributes) {
- this.run(LiquibaseCommands.GenerateChangeLog, params);
- return this;
- }
-
- /**
- * The `--help` command lists all the available Liquibase commands, required and optional parameters, and changelog property. The command also presents Liquibase Hub commands— registerChangeLog, syncHub, and the hubAPIKey property with the definitions.
- *
- * @description The `--help` command is typically used to check the syntax of commands, their definitions, and parameters. The command provides the output that includes the following:
- * - Standard commands
- * - Diff commands
- * - Documentation commands
- * - Maintenance commands
- * - Hub commands
- * - Required parameters
- * - Optional parameters
- * - Required diff parameters
- * - Optional diff parameters
- * - changelog properties
- * - Hub integration CLI parameter
- *
- * {@link https://docs.liquibase.com/commands/community/help.html Documentation}
- */
- public help() {
- this.run(LiquibaseCommands.Help);
- return this;
- }
-
- /**
- * The `history` command is a helper command that lists out all your deploymentIds and all changesets associated with each deploymentId.
- *
- * @description The `history` command is typically used when you want to inspect a particular group of changes to ensure that they have been applied to the database.
- *
- * {@link https://docs.liquibase.com/commands/community/history.html Documentation}
- */
- public history() {
- this.run(LiquibaseCommands.History);
- return this;
- }
-
- /**
- * `listLocks` returns the hostname, IP address, and the timestamp the Liquibase lock record was added to the DATABASECHANGELOGLOCK table.
- *
- * @description `listLocks` is typically used when an error occurs during a database deployment. The error might indicate that there is a lock record in the DATABASECHANGELOGLOCK table by another user that is preventing Liquibase from applying changes to the specified database.
- * `listLocks` will read the DATABASECHANGELOGLOCK table and return a list that includes the hostname, IP address, and the timestamp the lock record was granted to the DATABASECHANGELOGLOCK table and determines the connections to the DATABASECHANGELOGLOCK table based on the database URL.
- *
- * {@link https://docs.liquibase.com/commands/community/listlocks.html Documentation}
- */
- public listLocks() {
- this.run(LiquibaseCommands.ListLocks);
- return this;
- }
-
- /**
- * The `markNextChangeSetRan` command marks the next change you apply as executed in your database.
- *
- * @description The `markNextChangeSetRan` command is typically used when you have made a change manually, and the deployment is failing. Here is a use case that shows the whole process in more detail:
- * - You have a changelog with a specific changeset and want to create a table in your database, and then apply your changes manually without using Liquibase. In this case, there will be no record of this change in the DATABASECHANGELOG table.
- * - Then you decide to deploy the same changeset by using the `update` command, Liquibase checks the DATABASECHANGELOG table to see if there is such a changeset. Since there is no record of it, Liquibase tries to create a table, but as it already exists, you receive an error.
- * - As a result, Liquibase stops deployment at that specific changeset without executing it.
- * - Running the `markNextChangeSetRan` adds that changeset in the changelog as a record even though the table is already created. The command detects that the changeset was deployed.
- * Additionally, the best practice is to run the `markNextChangeSetRanSQL` helper command to inspect the `markNextChangeSetRan` SQL, so you can correct any issues that may arise before running the command.
- *
- * {@link https://docs.liquibase.com/commands/community/marknextchangesetran.html Documentation}
- */
- public markNextChangeSetRan() {
- this.run(LiquibaseCommands.MarkNextChangeSetRan);
- return this;
- }
-
- /**
- * The `markNextChangeSetRanSQL` command is a helper command that inspects the SQL Liquibase will run while using the markNextChangeSetRan command.
- *
- * @description The `markNextChangeSetRanSQL` command is used to inspect the raw SQL before running the markNextChangeSetRan command,
- * so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to mark the next changeset you apply as executed in your database and to keep that changeset in the changelog as a record assuming that it has already been deployed.
- *
- * {@link https://docs.liquibase.com/commands/community/marknextchangesetransql.html Documentation}
- */
- public markNextChangeSetRanSQL() {
- this.run(LiquibaseCommands.MarkNextChangeSetRanSql);
- return this;
- }
-
- /**
- * The `registerChangeLog` command connects your local Liquibase activity to a specific Liquibase Hub Project. By registering your changelog, this activity will be visible only to one Project within one Organization in Liquibase Hub.
- *
- * @description The `registerChangeLog` command is used to connect an XML or formatted SQL changelog to your Liquibase Hub Project. Also, you can use JSON and YAML changelog formats (since 4.2.1).
- * The command also assigns the changeLogId to the changelog file that you register. The changeLogId is a unique identifier in your changelog, which is automatically added by the `registerChangeLog` command to provide real-time monitoring and reports.
- * You can connect the needed changelog file with your existing project or create a new project from the CLI.
- *
- * {@link https://docs.liquibase.com/commands/community/registerchangelog.html Documentation}
- */
- public registerChangeLog() {
- this.run(LiquibaseCommands.RegisterChangeLog);
- return this;
- }
-
- /**
- * `releaseLocks` removes the specific Liquibase lock record from the DATABASECHANGELOGLOCK table in the needed database.
- *
- * @description `releaseLocks` is typically used when there was an interruption with the Liquibase process during deployment resulting from the DATABASECHANGELOGLOCK table being in a locked state.
- *
- * {@link https://docs.liquibase.com/commands/community/releaselocks.html Documentation}
- */
- public releaseLocks() {
- this.run(LiquibaseCommands.ReleaseLocks);
- return this;
- }
-
- /**
- * The `changelogSync` command marks all undeployed changes in your changelog as executed in your database.
- *
- * @description The `changelogSync` command is typically used when you want to baseline a new database environment.
- * An example use case for the `changelogSync` command is when you have a DEV environment with a set of objects used only in DEV, and you want to use the same changelog to manage a new TEST environment.
- * The TEST environment does not have or need, those DEV-only objects. To avoid deploying the DEV-only objects, you run the `changelogSync` command to mark those changes as executed in the DATABASECHANGELOG which tells Liquibase to treat these databases as equivalent.
- * You can also use the changeLogSync command to mark a change as executed if the object associated with the change was created manually on the database. By marking the changeset as executed, it prevents the next Liquibase update from failing as it tries to create an object that already exists.
- *
- * {@link https://docs.liquibase.com/commands/community/changelogsync.html Documentation}
- */
- public changelogSync() {
- this.run(LiquibaseCommands.ChangelogSync);
- return this;
- }
-
- /**
- * The `changelogSyncSQL` is a helper command that produces the raw SQL Liquibase would run when using the changelogSync command.
- *
- * @description The `changelogSyncSQL` command is typically used when you want to inspect the SQL Liquibase will use to baseline a new database environment.
- * It is best practice to inspect any SQL that Liquibase would run when using the changelogSync command so you can review any changes the command would make to your database before running the command.
- *
- * {@link https://docs.liquibase.com/commands/community/changelogsyncsql.html Documentation}
- */
- public changelogSyncSQL() {
- this.run(LiquibaseCommands.ChangelogSyncSql);
- return this;
- }
-
- /**
- * The `changelogSyncToTag` command marks all undeployed changesets from your changelog up to the specified tag as executed in your database. The command also marks the changeset with that tag as deployed.
- *
- * @param params Arguments/Attribute for the command.
- *
- * @description The `changelogSyncToTag` command is typically used when you want to baseline a new database environment with specific objects. An example use case for the `changelogSyncToTag` command is the following:
- * - You have a DEV environment with a set of objects used only in DEV, and you want to use the same changelog to manage a new TEST environment. The TEST environment does not have those DEV-only objects and needs only some of them.
- * - To deploy the needed DEV-only objects and avoid deploying the rest, you add a tag and run the `changelogSyncToTag` command to mark the changes related to that tag as executed in the DATABASECHANGELOG table.
- * - The command marks all changesets starting with the first changeset at the top of the DEV changelog file and moving down to the changesets up to and including the tag.
- * - Next, you deploy the changesets that were not marked as deployed in your database. Liquibase treats your DEV and TEST databases as equivalent.
- *
- * {@link https://docs.liquibase.com/commands/community/changelogsynctotag.html Documentation}
- */
- public changelogSyncToTag(params: ChangelogSyncToTagCommandAttributes) {
- this.run(LiquibaseCommands.ChangelogSyncToTag, params);
- return this;
- }
-
- /**
- * The `changelogSyncToTagSQL` is a helper command that produces the raw SQL that Liquibase would run when using the changelogSyncToTag command to mark all undeployed changesets associated with the specified tag as executed in your database.
- *
- * @param params Arguments/Attribute for the command.
- *
- * @description The `changelogSyncToTagSQL` command is typically used when you want to inspect the SQL Liquibase will use to baseline a new database environment.
- * It is best practice to inspect any SQL that Liquibase would run when using the changelogSyncToTag command so you can review any changes the command would make to your database before running it.
- * The changelogSyncToTag command marks all changesets starting with the first changeset at the top of the changelog file and moving down to the changeset up to and including the tag.
- *
- * {@link https://docs.liquibase.com/commands/community/changelogsynctotagsql.html Documentation}
- */
- public changelogSyncToTagSQL(params: ChangelogSyncToTagSQLCommandAttributes) {
- this.run(LiquibaseCommands.ChangelogSyncToTagSql, params);
- return this;
- }
-
- /**
- * The `clearCheckSums` clears all checksums and nullifies the MD5SUM column of the DATABASECHANGELOG table so they will be re-computed on the next database update.
- *
- * @description `clearCheckSums` is typically used when there is a [MD5Sum Check Failed] error message and there is a need to clear the checksums from the DATABASECHANGELOG table.
- *
- * {@link https://docs.liquibase.com/commands/community/clearchecksums.html Documentation}
- */
- public clearCheckSums() {
- this.run(LiquibaseCommands.ClearCheckSums);
- return this;
- }
-
- /**
- * The `dbDoc ` command generates documentation in a Javadoc format based on the existing database and changelogs.
- *
- * @param params Arguments/Attribute for the command.
- *
- * @description The `dbDoc ` command is typically used to generate database documentation with the change information stored in the changelogs and the existing database.
- * It captures the current state of your database including everything that has been performed against it.
- *
- * {@link https://docs.liquibase.com/commands/community/dbdoc.html Documentation}
- */
- public dbDoc(params: DbDocCommandAttributes) {
- this.run(LiquibaseCommands.DbDoc, params);
- return this;
- }
-
- /**
- * The `deactivateChangeLog` command removes the changelogID from your changelog file so it stops sending reports to Liquibase Hub.
- *
- * @description The `deactivateChangeLog` command is typically used when:
- * - You start using Liquibase Hub to keep a history of all your activity, but you have registered the wrong changelog file and want to keep it from reporting the activity to Liquibase Hub.
- * - You use a changelog file that is being secluded or refactored into other changelogs and do not want more than one source of changesets reporting to Liquibase Hub.
- * When you run the `deactivateChangeLog` command, it modifies a specific changelog file by removing changelogID to prevent it from sending the data. The command differs from the liquibase.hub.mode=off property, which is set in your defaults file (the liquibase.properties file) or passed as a JAVA property and prevents any changelog from sending data.
- *
- * {@link https://docs.liquibase.com/commands/community/deactivatechangelog.html Documentation}
- */
- public deactivateChangeLog() {
- this.run(LiquibaseCommands.DeactivateChangeLog);
- return this;
- }
-
- /**
- * The `diff` command in Liquibase allows you to compare two databases of the same type, or different types, to one another.
- *
- * @param params Arguments/Attribute for the command.
- *
- * @description The `diff` command is typically used at the completion of a project to verify all expected changes are in the changelog or to detect drift between a model schema and a database's actual schema.
- * The `diff` command is also useful for the following tasks:
- * - Finding missing objects between one database and another
- * - Seeing that a change was made to your database
- * - Finding unexpected items in your database
- *
- * {@link https://docs.liquibase.com/commands/community/diff.html Documentation}
- */
- public diff(params: DiffCommandAttributes) {
- this.run(LiquibaseCommands.Diff, params);
- return this;
- }
-
- /**
- * The `diffChangeLog` command allows you to receive information on differences between two databases you are comparing and creates a changelog file containing deployable changesets.
- * The `diffChangeLog` command points out the differences in general and generates changes to resolve most of them.
- *
- * @param params Arguments/Attribute for the command.
- *
- * @description The `diffChangeLog` command is typically used when you want to create a deployable changelog to synchronize multiple databases.
- * The `diffChangeLog` command also provides more information about:
- * - Missing objects in your database
- * - Changes made to your database
- * - Unexpected items in your database
- *
- * {@link https://docs.liquibase.com/commands/community/diffchangelog.html Documentation}
- */
- public diffChangelog(params: DiffChangelogCommandAttributes) {
- this.run(LiquibaseCommands.DiffChangeLog, params);
- return this;
- }
-
- private stringifyParams(params: { [key: string]: any }): string {
- let commandString = '';
-
- for (const property in params) {
- const targetValue = params[property];
- commandString += `--${property}=${JSON.stringify(targetValue)} `
- }
-
- return commandString;
- }
-
- private loadParamsFromLiquibasePropertiesFileOnDemands(liquibasePropertyPath?: string): LiquibaseConfig | undefined {
- let paramsFromLiquibasePropertyFile: { [key: string]: string } = {};
-
- if (!liquibasePropertyPath) {
- return;
- }
-
- const fileContents = FileHelper.readFileContent(liquibasePropertyPath);
- const fileContentsLines = fileContents.split(/\r?\n/);
-
- fileContentsLines.forEach(line => {
- const keyValuePair = line.split(/=?:/, 2);
- const key = keyValuePair[0];
- const value = keyValuePair[1];
-
- if (paramsFromLiquibasePropertyFile.hasOwnProperty(key)) {
- paramsFromLiquibasePropertyFile[key.trim()] = value.trim();
- }
- });
-
- return paramsFromLiquibasePropertyFile as any as LiquibaseConfig;
- }
-
- /**
- * LEGACY CODE START
- */
- /**
- * Spawns a Liquibase command.
- * @param {*} action a string for the Liquibase command to run. Defaults to `'update'`
- * @param {*} params any parameters for the command
- * @returns {Promise} Promise of a node child process.
- */
- private run(action: LiquibaseCommands, params: { [key: string]: any } = {}) {
- const paramsFromLiquibasePropertyFile = this.loadParamsFromLiquibasePropertiesFileOnDemands(this.params.liquibasePropertiesFile);
- const mergedParams = { ...paramsFromLiquibasePropertyFile, ...this.params }
- const commandParamsString = this.stringifyParams(params);
- return this.spawnChildProcess(`${this.liquibasePathAndGlobalAttributes(mergedParams)} ${action} ${commandParamsString}`);
- }
-
- /**
- * Internal method that returns a node child process compatible command string.
- * @returns {string}
- * @private
- */
- private liquibasePathAndGlobalAttributes(params: LiquibaseConfig) {
- let liquibasePathAndGlobalAttributes = `${params.liquibase}`;
- Object.keys(params).forEach(key => {
- if (key === 'liquibase' || key == 'liquibasePropertiesFile') {
- return;
- }
- const value = (this.params as { [key: string]: any })[key];
- liquibasePathAndGlobalAttributes = `${liquibasePathAndGlobalAttributes} --${key}="${value}"`;
- });
- return liquibasePathAndGlobalAttributes;
- }
-
- /**
- *
- * Internal method for executing a child process.
- * @param {*} commandString Liquibase commandString
- */
- // private spawnChildProcess(commandString: string): Promise {
- private spawnChildProcess(commandString: string): Promise {
- return CommandHandler.spawnChildProcess(commandString);
- }
-
- /**
- * For now, we will assume Postgres is the 'default' database type.
- * In the future we can be smarter about how we merge these configs.
- *
- * @param params User Provided `LiquibaseConfig`
- */
- private mergeParamsWithDefaults(params: LiquibaseConfig) {
- const defaults: LiquibaseConfig = {
- ...POSTGRESQL_DEFAULT_CONFIG,
- // liquibase: join(__dirname, '../bin/liquibase/liquibase'), // NOTE: Changed this while debuggin.
- liquibase: FileHelper.bundledLiquibasePath,
- }
- this.params = Object.assign({}, defaults, params);
- }
-
- /**
- * LEGACY CODE END
- **/
+ private commandHandler: CommandHandler;
+ /**
+ * @description Returns an instance of a lightweight Node wrapper for Liquibase.
+ *
+ * @param config Configuration for an instance of `Liquibase`
+ *
+ * * @example
+ * ```typescript
+ * import {
+ * LiquibaseConfig,
+ * Liquibase,
+ * POSTGRESQL_DEFAULT_CONFIG,
+ * } from '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();
+ * ```
+ */
+ constructor(private config: LiquibaseConfig) {
+ this.mergeConfigWithDefaults(config);
+ this.commandHandler = new CommandHandler(this.config);
+ }
+
+ /**
+ * The `update` command deploys any changes that are in the changelog file and that have not been deployed to your database yet.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `update` command is typically used to apply database changes that are specified in the changelog file to your database.
+ * When you run the `update` command, Liquibase sequentially reads changesets in the changelog file, then it compares the unique identifiers of id, author, and path to filename to the values stored in the DATABASECHANGELOG table.
+ * - If the unique identifiers do not exist, Liquibase will apply the changeset to the database
+ * - If the unique identifiers exist, the MD5Sum of the changeset is compared to the one in the database
+ * - If they are different, Liquibase will produce an error message that someone has changed it unexpectedly. However, if the status of the runOnChange or runAlways changeset attribute is set to TRUE, Liquibase will re-apply the changeset
+ *
+ * {@link https://docs.liquibase.com/commands/community/update.html Documentation}
+ */
+ public update(params: WithOptionalSubstitutionParams): Promise {
+ return this.run(LiquibaseCommands.Update, params);
+ }
+
+ /**
+ * The `updateSQL` command is a helper command that allows you to inspect the SQL Liquibase will run while using the `update` command.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `updateSQL` command is used when you want to inspect the raw SQL before running the `update` command, so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to apply database changes you have added to the changelog file.
+ *
+ * {@link https://docs.liquibase.com/commands/community/updatesql.html Documentation}
+ */
+ public updateSQL(params: UpdateSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.UpdateSql, params);
+ }
+
+ /**
+ * The `updateCount ` command updates a specified number of changesets, where is the number of changesets you want to update sequentially on your database.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `updateCount ` command is mainly used when you want to apply changes and update changesets sequentially, starting with the changesets from the top of the changelog file until the number specified is reached.
+ *
+ * {@link https://docs.liquibase.com/commands/community/updatecount.html Documentation}
+ */
+ public updateCount(params: UpdateCountCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.UpdateCount, params);
+ }
+
+ /**
+ * The `updateCountSQL ` command is a helper command that inspects the SQL Liquibase will run while using the `updateCount ` command.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `updateCountSQL ` command is used to inspect the raw SQL before running the `updateCount ` command, so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to apply a specified number of database changes you have added to the changelog file.
+ *
+ * {@link https://docs.liquibase.com/commands/community/updatecountsql.html Documentation}
+ */
+ public updateCountSQL(params: UpdateCountSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.UpdateCountSql, params);
+ }
+
+ /**
+ * `updateTestingRollback` tests rollback support by deploying all pending changesets to the database, executes a rollback sequentially for the equal number of changesets that were deployed, and then runs the update again deploying all changesets to the database.
+ *
+ * @description `updateTestingRollback` is typically used when you want to test rollback functionality when deploying changesets in your changelog sequentially. Run `updateTestingRollback` only when all pending changelogs have been verified as ready to be deployed as you cannot specify changesets to exclude.
+ * `updateTestingRollback` utilizes a multi-step operation and runs in sequential order:
+ * - update changeset1; update changeset2; update changeset3
+ * - rollback changeset3; rollback changeset2; rollback changeset1
+ * - update changeset1; update changeset2 update changeset3
+ *
+ * {@link https://docs.liquibase.com/commands/community/updatetestingrollback.html Documentation}
+ */
+ public updateTestingRollback(): Promise {
+ return this.run(LiquibaseCommands.UpdateTestingRollback);
+ }
+
+ /**
+ * The `updateToTag ` command applies sequential changes to your database from the newest changeset to the changeset with the tag you specified and applied earlier.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `updateToTag ` command is mainly used to apply changes sequentially, starting with the changesets from the top of the changelog file until the specified tag is reached. Even though there are other undeployed changes in the changelog, the command deploys only the changesets associated with a specific tag.
+ *
+ * {@link https://docs.liquibase.com/commands/community/updatetotag.html Documentation}
+ */
+ public updateToTag(params: UpdateToTagCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.UpdateToTag, params);
+ }
+
+ /**
+ * The `updateToTagSQL ` command is a helper command that inspects the SQL Liquibase will run while using the `updateToTag ` command.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `updateToTagSQL ` command is used to inspect the raw SQL before running the `updateToTag ` command, so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to apply database changes you have added to the changelog file based on the tag specified.
+ *
+ * {@link https://docs.liquibase.com/commands/community/updatetotagsql.html Documentation}
+ */
+ public updateToTagSQL(params: UpdateToTagSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.UpdateToTagSql, params);
+ }
+
+ /**
+ * The `validate` command checks and identifies any possible errors in a changelog that can cause the `update` command to fail.
+ *
+ * @description The `validate` command is mainly used when you want to detect if there are any issues with a changelog before running the `update` command.
+ * With the help of the `validate` command, you can avoid a partial update, where only some changesets are applied due to an error in your changelog file.
+ * Use the validate command to ensure that:
+ * - The XML/YAML/JSON/formatted SQL is structured correctly
+ * - Referenced files can be found
+ * - There are no duplicated id/author/file combinations
+ * - There aren't any checksum errors
+ * - Any required or not allowed attributes are correct for your database
+ *
+ * {@link https://docs.liquibase.com/commands/community/validate.html Documentation}
+ */
+ public validate(): Promise {
+ return this.run(LiquibaseCommands.Validate);
+ }
+
+ /**
+ * The `calculateCheckSum ` command calculates and prints a checksum for the changeset with the specified id in the following format: filepath::id::author.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `calculateCheckSum ` command is typically used to compute an MD5 checksum, which serves as a unique identifier for the changeset. As a result, you can see whether the changeset has been changed and whether it has to be deployed differently now.
+ * When running the `calculateCheckSum ` command, the DATABASECHANGELOG table calculates an MD5 checksum for each entry based on the SQL script of the changeset. This checksum helps Liquibase detect differences between the changesets you want to deploy and the changesets that have already been run against the database.
+ * The MD5SUM column in the DATABASECHANGELOG table contains a checksum of the changeset and any change made in the changeset will result in a different checksum.
+ *
+ * {@link https://docs.liquibase.com/commands/community/calculatechecksum.html Documentation}
+ */
+ public calculateCheckSum(params: CalculateCheckSumCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.CalculateCheckSum, params);
+ }
+
+ /**
+ * The `rollback ` command rolls back changes made to the database based on the specified tag.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `rollback ` command is typically used to revert all changes that were made to the database after the tag you specify.
+ * When you run `rollback `, Liquibase will roll back sequentially all the deployed changes until it reaches the tag row in the DATABASECHANGELOG table.
+ * For example, you can use the `rollback ` command when you want to undo a series of changes made to your database related to a specific tag such as a numbered release.
+ * If you have tags for release 1, release 2, and release 3, and need to make a correction in release 2, the `rollback ` command will rollback release 3 first.
+ *
+ * {@link https://docs.liquibase.com/commands/community/rollbackbytag.html Documentation}
+ */
+ public rollback(params: RollbackCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.Rollback, params);
+ }
+
+ /**
+ * The `rollbackSQL ` is a helper command that produces the raw SQL Liquibase would run when using the rollback command.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `rollbackSQL ` command is typically used to inspect the SQL Liquibase uses to revert changes associated with a tag you specify when you run the `rollback ` command.
+ * It is best practice to use the `rollbackSQL ` command before running the `rollback ` command to ensure that you eliminate any potential risks.
+ *
+ * {@link https://docs.liquibase.com/commands/community/rollbacksqltag.html Documentation}
+ */
+ public rollbackSQL(params: RollbackSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.RollbackSql, params);
+ }
+
+ /**
+ * The `rollbackCount ` command reverts a specified number of changesets, where is the number of changesets you want to revert sequentially on your database.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `rollbackCount ` command is used when you want to roll back changes sequentially,
+ * starting with the most recent changes and working backward until the value specified is reached.
+ *
+ * {@link https://docs.liquibase.com/commands/community/rollbackcount.html Documentation}
+ */
+ public rollbackCount(params: RollbackCountCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.RollbackCount, params);
+ }
+
+ /**
+ * The `rollbackCountSQL ` command is a helper command that allows you to inspect the SQL Liquibase will run while using the `rollbackCount ` command.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `rollbackCountSQL ` command is used when you want to inspect the raw SQL before running the `rollbackCount ` command,
+ * so you can correct any issues that may arise before running the command.
+ * Liquibase uses the raw SQL to revert any changesets between the most recent and the value you specified.
+ *
+ * {@link https://docs.liquibase.com/commands/community/rollbackcountsql.html Documentation}
+ */
+ public rollbackCountSQL(params: RollbackCountSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.RollbackCountSql, params);
+ }
+
+ /**
+ * The `rollbackToDate` command reverts your database to the state it was in at the date and time you specify.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `rollbackToDate` command is mainly used when you want to revert all changes made to your database from today's date to the date and time you specify.
+ * The `rollbackToDate` command reverts those changesets to their previous state and allows you to target the date and time without impacting changes or deployments that came before the date and time you specified.
+ *
+ * {@link https://docs.liquibase.com/commands/community/rollbacktodate.html Documentation}
+ */
+ public rollbackToDate(params: RollbackToDateCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.RollbackToDate, params);
+ }
+
+ /**
+ * The `rollbackToDateSQL` command is a helper command that allows you to inspect the SQL Liquibase will run while using the rollbackToDate command.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `rollbackToDateSQL` command is typically used when you want to inspect the raw SQL before running the rollbackToDate command,
+ * so you can correct any issues that may arise before running the command.
+ *
+ * {@link https://docs.liquibase.com/commands/community/rollbacktodatesql.html Documentation}
+ */
+ public rollbackToDateSQL(params: RollbackToDateSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.RollbackToDateSql, params);
+ }
+
+ /**
+ * The `snapshot` command captures the current state of the URL database, which is the target database.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `snapshot` command is typically used when you want to see changes in your target database or keep a record of your current database state.
+ * The `snapshot` command has two modes:
+ * - When run without options, it gathers the current state of the database and shows a text-based version of the schema to STDOUT.
+ * - When run with the --snapshotFormat=JSON option, it creates a JSON file that represents the current state of the URL database.
+ * Alternatively, you can have a YAML-based output by using the --snapshotFormat=yaml attribute.
+ *
+ * {@link https://docs.liquibase.com/commands/community/snapshot.html Documentation}
+ */
+ public snapshot(params: SnapshotCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.Snapshot, params);
+ }
+
+ /**
+ * The `snapshotReference` command captures the current state of the referenceURL database, which is the source database.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `snapshotReference` command is typically used when you want to see changes in your source database or keep a record of your current database state.
+ * The snapshot command has two modes:
+ * - When run without options, it gathers the current state of the database and shows a text-based version of the schema to STDOUT.
+ * - When run with the --snapshotFormat=JSON option, it creates a JSON file that represents the current state of the referenceURL database.
+ * Alternatively, you can have a YAML-based output by using the --snapshotFormat=yaml attribute.
+ *
+ * {@link https://docs.liquibase.com/commands/community/snapshotreference.html Documentation}
+ */
+ public snapshotReference(params: SnapshotReferenceCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.SnapshotReference, params);
+ }
+
+ /**
+ * The `status --verbose` command produces a list of pending changesets with additional information that includes the id, author, and file path name.
+ * The `status --verbose` command does not modify the database.
+ *
+ * @description The `status --verbose` command is typically used when changesets were added to a changelog through source control by another developer.
+ * The command confirms what has been deployed and what changesets are pending per author and corresponding ids.
+ *
+ * {@link https://docs.liquibase.com/commands/community/status-verbose.html Documentation}
+ */
+ public status(): Promise {
+ return this.run(LiquibaseCommands.Status);
+ }
+
+ /**
+ * The `syncHub` command synchronizes the local DATABASECHANGELOG table with Liquibase Hub.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `syncHub` command is typically used when you want to:
+ * - Ensure that Liquibase Hub shows the latest results from your DATABASECHANGELOG table.
+ * - Synchronize the DATABASECHANGELOG table of a new project that has pre-existing data in the DATABASECHANGELOG table.
+ * - Synchronize your local data if update, rollback, changelogSync, or dropAll were run while Liquibase Hub was offline.
+ * When you run the `syncHub` command, you will not see any operations added to the Project associated with your changelog.
+ * syncHub cannot associate previous Liquibase operations, so you will not see any operations in Liquibase Hub.
+ * You will only see changesets added to the changesets tab in your Liquibase Hub project.
+ *
+ * {@link https://docs.liquibase.com/commands/community/synchub.html Documentation}
+ */
+ public syncHub(params: SyncHubCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.SyncHub, params);
+ }
+
+ /**
+ * The `tag ` command marks the current database state so you can roll back changes in the future.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `tag ` command is typically used to mark the current database state, version, release, or any other information by adding the tag to the last row in the DATABASECHANGELOG table.
+ * After setting the tag, you can use the `rollback ` command to roll back all changes under this tag.
+ *
+ * {@link https://docs.liquibase.com/commands/community/tag.html Documentation}
+ */
+ public tag(params: TagCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.Tag, params);
+ }
+
+ /**
+ * The `tagExists ` command checks whether the tag you specify already exists in your database.
+ *
+ * @param params - Arguments/Attribute for the command.
+ *
+ * @description The `tagExists ` command is typically used to identify whether the specified tag exists in the database or specifically in the DATABASECHANGELOG table.
+ * Running the `tagExists ` command checks for the tag and, based on whether it exists or not, provides the appropriate output.
+ *
+ * {@link https://docs.liquibase.com/commands/community/tagexists.html Documentation}
+ */
+ public tagExists(params: TagExistsCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.TagExists, params);
+ }
+
+ /**
+ * The `unexpectedChangeSets` command produces a list of changesets that were run in the database but do not exist in the current changelog.
+ *
+ * @description The `unexpectedChangeSets` command is typically used to detect and compare the changes between the DATABASECHANGELOG table and the current changelog.
+ * If any of the changesets in the DATABASECHANGELOG table do not exist in the current changelog, the `unexpectedChangeSets` command will detect those changesets and produce them in your output.
+ * The `unexpectedChangeSets` command also produces all the changesets that were previously deployed and deleted from your current changelog.
+ *
+ * {@link https://docs.liquibase.com/commands/community/unexpectedchangesets.html Documentation}
+ */
+ public unexpectedChangeSets(): Promise {
+ return this.run(LiquibaseCommands.UnexpectedChangeSets);
+ }
+
+ /**
+ * `dropAll` drops all database objects owned by the user. `dropAll` will not drop functions, procedures, or packages for the community version of Liquibase. Functions, procedures, packages, and synonyms can only be dropped for Liquibase Pro supported objects.
+ *
+ * @description `dropAll` is typically used when there is a need to prepare an environment schema to be identical to another environment schema. `dropAll` is useful in the developer and test environments to remove unwanted objects to reset the database to “empty”.
+ * The command makes it easier to standardize another schema, compared to manually deleting the objects, or dropping and recreating the desired schema.
+ * `dropAll` should not be used in a production environment to prevent removal of required objects.
+ *
+ * {@link https://docs.liquibase.com/commands/community/dropall.html Documentation}
+ */
+ public dropAll(): Promise {
+ return this.run(LiquibaseCommands.DropAll);
+ }
+
+ /**
+ * The `futureRollbackSQL` command is a helper command that produces the raw SQL Liquibase would need to roll back changes that have not yet been deployed to your database.
+ *
+ * @description You can use the `futureRollbackSQL` command to inspect the raw SQL Liquibase would use to revert changes associated with undeployed changesets.
+ * It is best practice to inspect SQL Liquibase would run when using the `update` command so you can review any changes the command would make to your database.
+ *
+ * {@link https://docs.liquibase.com/commands/community/futurerollbacksql.html Documentation}
+ */
+ public futureRollbackSQL(): Promise {
+ return this.run(LiquibaseCommands.FutureRollbackSql);
+ }
+
+ /**
+ * The `futureRollbackCountSQL ` command generates the SQL that Liquibase would use to sequentially revert the number of changes associated with undeployed changesets, which are added to a changelog file.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `futureRollbackCountSQL ` command is typically used to inspect the SQL before rolling back the number of changesets that you have not deployed to your database but added to your changelog. The command shows the output starting with the most recent changes until the value specified is reached.
+ * It is best practice to inspect SQL, which Liquibase would run when using the rollback command so you can review any changes the command would make to your database.
+ *
+ * {@link https://docs.liquibase.com/commands/community/futurerollbackcountsql.html Documentation}
+ */
+ public futureRollbackCountSQL(params: FutureRollbackCountSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.FutureRollbackCountSql, params);
+ }
+
+ /**
+ * The `generateChangeLog` command creates a changelog file that has a sequence of changesets which describe how to re-create the current state of the database.
+ *
+ * @param params Arguments/Attributes for the command
+ *
+ * @description The `generateChangeLog` command is typically used when you want to capture the current state of a database, then apply those changes to any number of databases. This is typically only done when a project has an existing database, but hasn't used Liquibase before.
+ * See {@link https://docs.liquibase.com/workflows/liquibase-community/existing-project.html How to set up Liquibase with an Existing Project and Multiple Environments} for more details.
+ *
+ * {@link https://docs.liquibase.com/commands/community/generatechangelog.html Documentation}
+ */
+ public generateChangeLog(params: GenerateChangeLogCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.GenerateChangeLog, params);
+ }
+
+ /**
+ * The `--help` command lists all the available Liquibase commands, required and optional parameters, and changelog property. The command also presents Liquibase Hub commands— registerChangeLog, syncHub, and the hubAPIKey property with the definitions.
+ *
+ * @description The `--help` command is typically used to check the syntax of commands, their definitions, and parameters. The command provides the output that includes the following:
+ * - Standard commands
+ * - Diff commands
+ * - Documentation commands
+ * - Maintenance commands
+ * - Hub commands
+ * - Required parameters
+ * - Optional parameters
+ * - Required diff parameters
+ * - Optional diff parameters
+ * - changelog properties
+ * - Hub integration CLI parameter
+ *
+ * {@link https://docs.liquibase.com/commands/community/help.html Documentation}
+ */
+ public help(): Promise {
+ return this.run(LiquibaseCommands.Help);
+ }
+
+ /**
+ * The `history` command is a helper command that lists out all your deploymentIds and all changesets associated with each deploymentId.
+ *
+ * @description The `history` command is typically used when you want to inspect a particular group of changes to ensure that they have been applied to the database.
+ *
+ * {@link https://docs.liquibase.com/commands/community/history.html Documentation}
+ */
+ public history(): Promise {
+ return this.run(LiquibaseCommands.History);
+ }
+
+ /**
+ * `listLocks` returns the hostname, IP address, and the timestamp the Liquibase lock record was added to the DATABASECHANGELOGLOCK table.
+ *
+ * @description `listLocks` is typically used when an error occurs during a database deployment. The error might indicate that there is a lock record in the DATABASECHANGELOGLOCK table by another user that is preventing Liquibase from applying changes to the specified database.
+ * `listLocks` will read the DATABASECHANGELOGLOCK table and return a list that includes the hostname, IP address, and the timestamp the lock record was granted to the DATABASECHANGELOGLOCK table and determines the connections to the DATABASECHANGELOGLOCK table based on the database URL.
+ *
+ * {@link https://docs.liquibase.com/commands/community/listlocks.html Documentation}
+ */
+ public listLocks(): Promise {
+ return this.run(LiquibaseCommands.ListLocks);
+ }
+
+ /**
+ * The `markNextChangeSetRan` command marks the next change you apply as executed in your database.
+ *
+ * @description The `markNextChangeSetRan` command is typically used when you have made a change manually, and the deployment is failing. Here is a use case that shows the whole process in more detail:
+ * - You have a changelog with a specific changeset and want to create a table in your database, and then apply your changes manually without using Liquibase. In this case, there will be no record of this change in the DATABASECHANGELOG table.
+ * - Then you decide to deploy the same changeset by using the `update` command, Liquibase checks the DATABASECHANGELOG table to see if there is such a changeset. Since there is no record of it, Liquibase tries to create a table, but as it already exists, you receive an error.
+ * - As a result, Liquibase stops deployment at that specific changeset without executing it.
+ * - Running the `markNextChangeSetRan` adds that changeset in the changelog as a record even though the table is already created. The command detects that the changeset was deployed.
+ * Additionally, the best practice is to run the `markNextChangeSetRanSQL` helper command to inspect the `markNextChangeSetRan` SQL, so you can correct any issues that may arise before running the command.
+ *
+ * {@link https://docs.liquibase.com/commands/community/marknextchangesetran.html Documentation}
+ */
+ public markNextChangeSetRan(): Promise {
+ return this.run(LiquibaseCommands.MarkNextChangeSetRan);
+ }
+
+ /**
+ * The `markNextChangeSetRanSQL` command is a helper command that inspects the SQL Liquibase will run while using the markNextChangeSetRan command.
+ *
+ * @description The `markNextChangeSetRanSQL` command is used to inspect the raw SQL before running the markNextChangeSetRan command,
+ * so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to mark the next changeset you apply as executed in your database and to keep that changeset in the changelog as a record assuming that it has already been deployed.
+ *
+ * {@link https://docs.liquibase.com/commands/community/marknextchangesetransql.html Documentation}
+ */
+ public markNextChangeSetRanSQL(): Promise {
+ return this.run(LiquibaseCommands.MarkNextChangeSetRanSql);
+ }
+
+ /**
+ * The `registerChangeLog` command connects your local Liquibase activity to a specific Liquibase Hub Project. By registering your changelog, this activity will be visible only to one Project within one Organization in Liquibase Hub.
+ *
+ * @description The `registerChangeLog` command is used to connect an XML or formatted SQL changelog to your Liquibase Hub Project. Also, you can use JSON and YAML changelog formats (since 4.2.1).
+ * The command also assigns the changeLogId to the changelog file that you register. The changeLogId is a unique identifier in your changelog, which is automatically added by the `registerChangeLog` command to provide real-time monitoring and reports.
+ * You can connect the needed changelog file with your existing project or create a new project from the CLI.
+ *
+ * {@link https://docs.liquibase.com/commands/community/registerchangelog.html Documentation}
+ */
+ public registerChangeLog(): Promise {
+ return this.run(LiquibaseCommands.RegisterChangeLog);
+ }
+
+ /**
+ * `releaseLocks` removes the specific Liquibase lock record from the DATABASECHANGELOGLOCK table in the needed database.
+ *
+ * @description `releaseLocks` is typically used when there was an interruption with the Liquibase process during deployment resulting from the DATABASECHANGELOGLOCK table being in a locked state.
+ *
+ * {@link https://docs.liquibase.com/commands/community/releaselocks.html Documentation}
+ */
+ public releaseLocks(): Promise {
+ return this.run(LiquibaseCommands.ReleaseLocks);
+ }
+
+ /**
+ * The `changelogSync` command marks all undeployed changes in your changelog as executed in your database.
+ *
+ * @description The `changelogSync` command is typically used when you want to baseline a new database environment.
+ * An example use case for the `changelogSync` command is when you have a DEV environment with a set of objects used only in DEV, and you want to use the same changelog to manage a new TEST environment.
+ * The TEST environment does not have or need, those DEV-only objects. To avoid deploying the DEV-only objects, you run the `changelogSync` command to mark those changes as executed in the DATABASECHANGELOG which tells Liquibase to treat these databases as equivalent.
+ * You can also use the changeLogSync command to mark a change as executed if the object associated with the change was created manually on the database. By marking the changeset as executed, it prevents the next Liquibase update from failing as it tries to create an object that already exists.
+ *
+ * {@link https://docs.liquibase.com/commands/community/changelogsync.html Documentation}
+ */
+ public changelogSync(): Promise {
+ return this.run(LiquibaseCommands.ChangelogSync);
+ }
+
+ /**
+ * The `changelogSyncSQL` is a helper command that produces the raw SQL Liquibase would run when using the changelogSync command.
+ *
+ * @description The `changelogSyncSQL` command is typically used when you want to inspect the SQL Liquibase will use to baseline a new database environment.
+ * It is best practice to inspect any SQL that Liquibase would run when using the changelogSync command so you can review any changes the command would make to your database before running the command.
+ *
+ * {@link https://docs.liquibase.com/commands/community/changelogsyncsql.html Documentation}
+ */
+ public changelogSyncSQL(): Promise {
+ return this.run(LiquibaseCommands.ChangelogSyncSql);
+ }
+
+ /**
+ * The `changelogSyncToTag` command marks all undeployed changesets from your changelog up to the specified tag as executed in your database. The command also marks the changeset with that tag as deployed.
+ *
+ * @param params Arguments/Attribute for the command.
+ *
+ * @description The `changelogSyncToTag` command is typically used when you want to baseline a new database environment with specific objects. An example use case for the `changelogSyncToTag` command is the following:
+ * - You have a DEV environment with a set of objects used only in DEV, and you want to use the same changelog to manage a new TEST environment. The TEST environment does not have those DEV-only objects and needs only some of them.
+ * - To deploy the needed DEV-only objects and avoid deploying the rest, you add a tag and run the `changelogSyncToTag` command to mark the changes related to that tag as executed in the DATABASECHANGELOG table.
+ * - The command marks all changesets starting with the first changeset at the top of the DEV changelog file and moving down to the changesets up to and including the tag.
+ * - Next, you deploy the changesets that were not marked as deployed in your database. Liquibase treats your DEV and TEST databases as equivalent.
+ *
+ * {@link https://docs.liquibase.com/commands/community/changelogsynctotag.html Documentation}
+ */
+ public changelogSyncToTag(params: ChangelogSyncToTagCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.ChangelogSyncToTag, params);
+ }
+
+ /**
+ * The `changelogSyncToTagSQL` is a helper command that produces the raw SQL that Liquibase would run when using the changelogSyncToTag command to mark all undeployed changesets associated with the specified tag as executed in your database.
+ *
+ * @param params Arguments/Attribute for the command.
+ *
+ * @description The `changelogSyncToTagSQL` command is typically used when you want to inspect the SQL Liquibase will use to baseline a new database environment.
+ * It is best practice to inspect any SQL that Liquibase would run when using the changelogSyncToTag command so you can review any changes the command would make to your database before running it.
+ * The changelogSyncToTag command marks all changesets starting with the first changeset at the top of the changelog file and moving down to the changeset up to and including the tag.
+ *
+ * {@link https://docs.liquibase.com/commands/community/changelogsynctotagsql.html Documentation}
+ */
+ public changelogSyncToTagSQL(params: ChangelogSyncToTagSQLCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.ChangelogSyncToTagSql, params);
+ }
+
+ /**
+ * The `clearCheckSums` clears all checksums and nullifies the MD5SUM column of the DATABASECHANGELOG table so they will be re-computed on the next database update.
+ *
+ * @description `clearCheckSums` is typically used when there is a [MD5Sum Check Failed] error message and there is a need to clear the checksums from the DATABASECHANGELOG table.
+ *
+ * {@link https://docs.liquibase.com/commands/community/clearchecksums.html Documentation}
+ */
+ public clearCheckSums(): Promise {
+ return this.run(LiquibaseCommands.ClearCheckSums);
+ }
+
+ /**
+ * The `dbDoc ` command generates documentation in a Javadoc format based on the existing database and changelogs.
+ *
+ * @param params Arguments/Attribute for the command.
+ *
+ * @description The `dbDoc ` command is typically used to generate database documentation with the change information stored in the changelogs and the existing database.
+ * It captures the current state of your database including everything that has been performed against it.
+ *
+ * {@link https://docs.liquibase.com/commands/community/dbdoc.html Documentation}
+ */
+ public dbDoc(params: DbDocCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.DbDoc, params);
+ }
+
+ /**
+ * The `deactivateChangeLog` command removes the changelogID from your changelog file so it stops sending reports to Liquibase Hub.
+ *
+ * @description The `deactivateChangeLog` command is typically used when:
+ * - You start using Liquibase Hub to keep a history of all your activity, but you have registered the wrong changelog file and want to keep it from reporting the activity to Liquibase Hub.
+ * - You use a changelog file that is being secluded or refactored into other changelogs and do not want more than one source of changesets reporting to Liquibase Hub.
+ * When you run the `deactivateChangeLog` command, it modifies a specific changelog file by removing changelogID to prevent it from sending the data. The command differs from the liquibase.hub.mode=off property, which is set in your defaults file (the liquibase.properties file) or passed as a JAVA property and prevents any changelog from sending data.
+ *
+ * {@link https://docs.liquibase.com/commands/community/deactivatechangelog.html Documentation}
+ */
+ public deactivateChangeLog(): Promise {
+ return this.run(LiquibaseCommands.DeactivateChangeLog);
+ }
+
+ /**
+ * The `diff` command in Liquibase allows you to compare two databases of the same type, or different types, to one another.
+ *
+ * @param params Arguments/Attribute for the command.
+ *
+ * @description The `diff` command is typically used at the completion of a project to verify all expected changes are in the changelog or to detect drift between a model schema and a database's actual schema.
+ * The `diff` command is also useful for the following tasks:
+ * - Finding missing objects between one database and another
+ * - Seeing that a change was made to your database
+ * - Finding unexpected items in your database
+ *
+ * {@link https://docs.liquibase.com/commands/community/diff.html Documentation}
+ */
+ public diff(params: DiffCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.Diff, params);
+ }
+
+ /**
+ * The `diffChangeLog` command allows you to receive information on differences between two databases you are comparing and creates a changelog file containing deployable changesets.
+ * The `diffChangeLog` command points out the differences in general and generates changes to resolve most of them.
+ *
+ * @param params Arguments/Attribute for the command.
+ *
+ * @description The `diffChangeLog` command is typically used when you want to create a deployable changelog to synchronize multiple databases.
+ * The `diffChangeLog` command also provides more information about:
+ * - Missing objects in your database
+ * - Changes made to your database
+ * - Unexpected items in your database
+ *
+ * {@link https://docs.liquibase.com/commands/community/diffchangelog.html Documentation}
+ */
+ public diffChangelog(params: DiffChangelogCommandAttributes): Promise {
+ return this.run(LiquibaseCommands.DiffChangeLog, params);
+ }
+
+ private stringifyParams(
+ action: LiquibaseCommands,
+ commandParameters: WithOptionalSubstitutionParams
+ ): string {
+ const commandAcceptsPropertyAsPositionalArgument = Object.values(CommandsWithPositionalArguments).includes(
+ action as any
+ );
+ const { positionalArguments, commandString } = this.getPositionalArgumentsAndCommandString(
+ commandParameters,
+ commandAcceptsPropertyAsPositionalArgument
+ );
+ const substitutionArguments = this.getSubstitutionArguments(commandParameters);
+
+ return `${positionalArguments} ${commandString} ${substitutionArguments}`;
+ }
+
+ private getPositionalArgumentsAndCommandString(
+ commandParameters: WithOptionalSubstitutionParams,
+ commandAcceptsPropertyAsPositionalArgument: boolean
+ ) {
+ let commandString = '';
+ let positionalArguments = '';
+
+ for (const property in commandParameters) {
+ const targetValue = commandParameters[property];
+
+ if (commandAcceptsPropertyAsPositionalArgument) {
+ positionalArguments += `${JSON.stringify(targetValue)} `;
+ } else {
+ commandString += `--${property}=${JSON.stringify(targetValue)} `;
+ }
+ }
+
+ return {
+ commandString,
+ positionalArguments,
+ };
+ }
+
+ private getSubstitutionArguments({ substitutionParams }: WithOptionalSubstitutionParams): string {
+ let substitutionArguments = '';
+
+ if (!substitutionParams) {
+ return substitutionArguments;
+ }
+
+ for (const property of Object.keys(substitutionParams)) {
+ substitutionArguments += ` -D${property}="${substitutionParams[property]}" `;
+ }
+
+ return substitutionArguments;
+ }
+
+ private loadParamsFromLiquibasePropertiesFileOnDemand(liquibasePropertyPath?: string): LiquibaseConfig | undefined {
+ let paramsFromLiquibasePropertyFile: { [key: string]: string } = {};
+
+ if (!liquibasePropertyPath) {
+ return;
+ }
+
+ const fileContents = FileHelper.readFileContent(liquibasePropertyPath);
+ const fileContentsLines = fileContents.split(/\r?\n/);
+
+ fileContentsLines.forEach(line => {
+ const keyValuePair = line.split(/=?:/, 2);
+ const key = keyValuePair[0];
+ const value = keyValuePair[1];
+
+ if (paramsFromLiquibasePropertyFile.hasOwnProperty(key)) {
+ paramsFromLiquibasePropertyFile[key.trim()] = value.trim();
+ }
+ });
+
+ return (paramsFromLiquibasePropertyFile as any) as LiquibaseConfig;
+ }
+
+ /**
+ * LEGACY CODE START
+ */
+ /**
+ * Spawns a Liquibase command.
+ * @param {*} action a string for the Liquibase command to run. Defaults to `'update'`
+ * @param {*} params any parameters for the command
+ * @returns {Promise} Promise of a node child process.
+ */
+ private run(action: LiquibaseCommands, params: WithOptionalSubstitutionParams = {}) {
+ const paramsFromLiquibasePropertyFile = this.loadParamsFromLiquibasePropertiesFileOnDemand(
+ this.config.liquibasePropertiesFile
+ );
+ const mergedParams = { ...paramsFromLiquibasePropertyFile, ...this.config };
+ const commandParamsString = this.stringifyParams(action, params);
+
+ return this.spawnChildProcess(
+ `${this.liquibasePathAndGlobalAttributes(mergedParams)} ${action} ${commandParamsString}`
+ );
+ }
+
+ /**
+ * Internal method that returns a node child process compatible command string.
+ * @returns {string}
+ * @private
+ */
+ private liquibasePathAndGlobalAttributes(params: LiquibaseConfig) {
+ let liquibasePathAndGlobalAttributes = `${params.liquibase}`;
+ Object.keys(params).forEach(key => {
+ if (key === 'liquibase' || key === 'liquibasePropertiesFile') {
+ return;
+ }
+ const value = (this.config as { [key: string]: any })[key];
+ liquibasePathAndGlobalAttributes = `${liquibasePathAndGlobalAttributes} --${key}="${value}"`;
+ });
+ return liquibasePathAndGlobalAttributes;
+ }
+
+ /**
+ *
+ * Internal method for executing a child process.
+ * @param {*} commandString Liquibase commandString
+ */
+ private spawnChildProcess(commandString: string): Promise {
+ return this.commandHandler.spawnChildProcess(commandString);
+ }
+
+ /**
+ * For now, we will assume Postgres is the 'default' database type.
+ * In the future we can be smarter about how we merge these configs.
+ *
+ * @param config User Provided `LiquibaseConfig`
+ */
+ private mergeConfigWithDefaults(config: LiquibaseConfig) {
+ const defaults: LiquibaseConfig = {
+ ...POSTGRESQL_DEFAULT_CONFIG,
+ liquibase: FileHelper.bundledLiquibasePath,
+ };
+ this.config = Object.assign({}, defaults, config);
+ }
+
+ /**
+ * LEGACY CODE END
+ **/
}
diff --git a/src/models/commands/changelog-sync-to-tag-command-attributes.model.ts b/src/models/commands/changelog-sync-to-tag-command-attributes.model.ts
index c4b5de7..29c29ac 100644
--- a/src/models/commands/changelog-sync-to-tag-command-attributes.model.ts
+++ b/src/models/commands/changelog-sync-to-tag-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface ChangelogSyncToTagCommandAttributes {
- /**
- * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
- */
- tag: string;
+ /**
+ * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
+ */
+ tag: string;
}
diff --git a/src/models/commands/changelog-sync-to-tag-sql-command-attributes.model.ts b/src/models/commands/changelog-sync-to-tag-sql-command-attributes.model.ts
index 2a28f5c..2f13de5 100644
--- a/src/models/commands/changelog-sync-to-tag-sql-command-attributes.model.ts
+++ b/src/models/commands/changelog-sync-to-tag-sql-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface ChangelogSyncToTagSQLCommandAttributes {
- /**
- * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
- */
- tag: string;
+ /**
+ * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
+ */
+ tag: string;
}
diff --git a/src/models/commands/db-doc-command-attributes.model.ts b/src/models/commands/db-doc-command-attributes.model.ts
index b841778..ff9590a 100644
--- a/src/models/commands/db-doc-command-attributes.model.ts
+++ b/src/models/commands/db-doc-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface DbDocCommandAttributes {
- /**
- * The directory where the database documentation is generated.
- */
- outputDirectory: string;
+ /**
+ * The directory where the database documentation is generated.
+ */
+ outputDirectory: string;
}
diff --git a/src/models/commands/diff-changelog-command-attributes.model.ts b/src/models/commands/diff-changelog-command-attributes.model.ts
index 216c571..2398bcc 100644
--- a/src/models/commands/diff-changelog-command-attributes.model.ts
+++ b/src/models/commands/diff-changelog-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface DiffChangelogCommandAttributes {
- /**
- * Path to file where diff output will be saved
- */
- outputFile?: string;
+ /**
+ * Path to file where diff output will be saved
+ */
+ outputFile?: string;
}
diff --git a/src/models/commands/diff-command-attributes.model.ts b/src/models/commands/diff-command-attributes.model.ts
index 88ab91d..3445421 100644
--- a/src/models/commands/diff-command-attributes.model.ts
+++ b/src/models/commands/diff-command-attributes.model.ts
@@ -1,18 +1,18 @@
export interface DiffCommandAttributes {
- /**
- * Path to file where diff output will be saved
- */
- outputFile?: string;
- /**
- * Liquibase allows you to use diffType attribute to filter the types of objects you want to compare.
- * Multiple filters can be added to the attribute as a comma-separated list.
- * If no diffTypes are specified, all objects are considered.
- */
- diffTypes?: string
- /**
- * Starting with Liquibase 3.9.0, you can automate drift detection at scale in your database schemas
- * with the Liquibase Pro machine-readable JSON diff output.
- * The diff --format=json command is a Liquibase Pro extension to the existing diff command.
- */
- format?: string
+ /**
+ * Path to file where diff output will be saved
+ */
+ outputFile?: string;
+ /**
+ * Liquibase allows you to use diffType attribute to filter the types of objects you want to compare.
+ * Multiple filters can be added to the attribute as a comma-separated list.
+ * If no diffTypes are specified, all objects are considered.
+ */
+ diffTypes?: string;
+ /**
+ * Starting with Liquibase 3.9.0, you can automate drift detection at scale in your database schemas
+ * with the Liquibase Pro machine-readable JSON diff output.
+ * The diff --format=json command is a Liquibase Pro extension to the existing diff command.
+ */
+ format?: string;
}
diff --git a/src/models/commands/future-rollback-count-sql-command-attributes.model.ts b/src/models/commands/future-rollback-count-sql-command-attributes.model.ts
index 8d6801f..e10d57a 100644
--- a/src/models/commands/future-rollback-count-sql-command-attributes.model.ts
+++ b/src/models/commands/future-rollback-count-sql-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface FutureRollbackCountSQLCommandAttributes {
- /**
- * The integer indicating the number of changes Liquibase would use to roll back
- */
- value: string;
+ /**
+ * The integer indicating the number of changes Liquibase would use to roll back
+ */
+ value: string;
}
diff --git a/src/models/commands/generate-changelog-command-attributes.model.ts b/src/models/commands/generate-changelog-command-attributes.model.ts
index 4bace90..ee35932 100644
--- a/src/models/commands/generate-changelog-command-attributes.model.ts
+++ b/src/models/commands/generate-changelog-command-attributes.model.ts
@@ -1,40 +1,40 @@
export interface GenerateChangeLogCommandAttributes {
- /**
- * Specifies the default database catalog to use.
- */
- defaultCatalogName?: string;
- /**
- * Specifies the default database schema to use.
- */
- defaultSchemaName?: string;
- /**
- * Specifies database schemas you want to include.
- */
- schemas?: Array;
- /**
- * Uses the names as schemaName instead of the real names on the generateChangeLog command.
- */
- outputSchemaAs?: Array;
- /**
- * Includes the catalog in a generated changesets if the value is true. The default value is false.
- */
- includeCatalog: boolean;
- /**
- * Includes the schema in a generated changesets if the value is true. The default value is false.
- */
- includeSchema?: boolean;
- /**
- * Includes the tablespace of tables and indexes in a generated changesets if the value is true. The default value is false.
- */
- includeTablespace?: boolean;
- /**
- * Sends the data output as a CSV file in the given directory.
- */
- dataOutputDirectory?: string;
- /**
- * Includes a list of diff types in a changelog file expressed as a comma-separated list (without spaces)
- * from: catalog, tables, functions, views, columns, indexes, foreignkeys, primarykeys,
- * uniqueconstraints, data, storedprocedure, triggers, sequences.
- */
- diffTypes?: string;
+ /**
+ * Specifies the default database catalog to use.
+ */
+ defaultCatalogName?: string;
+ /**
+ * Specifies the default database schema to use.
+ */
+ defaultSchemaName?: string;
+ /**
+ * Specifies database schemas you want to include.
+ */
+ schemas?: Array;
+ /**
+ * Uses the names as schemaName instead of the real names on the generateChangeLog command.
+ */
+ outputSchemaAs?: Array;
+ /**
+ * Includes the catalog in a generated changesets if the value is true. The default value is false.
+ */
+ includeCatalog: boolean;
+ /**
+ * Includes the schema in a generated changesets if the value is true. The default value is false.
+ */
+ includeSchema?: boolean;
+ /**
+ * Includes the tablespace of tables and indexes in a generated changesets if the value is true. The default value is false.
+ */
+ includeTablespace?: boolean;
+ /**
+ * Sends the data output as a CSV file in the given directory.
+ */
+ dataOutputDirectory?: string;
+ /**
+ * Includes a list of diff types in a changelog file expressed as a comma-separated list (without spaces)
+ * from: catalog, tables, functions, views, columns, indexes, foreignkeys, primarykeys,
+ * uniqueconstraints, data, storedprocedure, triggers, sequences.
+ */
+ diffTypes?: string;
}
diff --git a/src/models/commands/index.ts b/src/models/commands/index.ts
index c2b6ead..cccfe07 100644
--- a/src/models/commands/index.ts
+++ b/src/models/commands/index.ts
@@ -17,7 +17,7 @@ export * from './update-count-command-attributes.model';
export * from './update-count-sql-command-attributes.model';
export * from './update-sql-command-attributes.model';
export * from './update-to-tag-command-attributes.model';
-export * from './update-to-tag-sql-command-attributes.model'
+export * from './update-to-tag-sql-command-attributes.model';
export * from './changelog-sync-to-tag-command-attributes.model';
export * from './changelog-sync-to-tag-sql-command-attributes.model';
export * from './db-doc-command-attributes.model';
diff --git a/src/models/commands/rollback-command-attributes.model.ts b/src/models/commands/rollback-command-attributes.model.ts
index 07341c6..31fc18b 100644
--- a/src/models/commands/rollback-command-attributes.model.ts
+++ b/src/models/commands/rollback-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface RollbackCommandAttributes {
- /**
- * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
- */
- tag: string;
+ /**
+ * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
+ */
+ tag: string;
}
diff --git a/src/models/commands/rollback-count-command-attributes.model.ts b/src/models/commands/rollback-count-command-attributes.model.ts
index af7b1d8..78acae5 100644
--- a/src/models/commands/rollback-count-command-attributes.model.ts
+++ b/src/models/commands/rollback-count-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface RollbackCountCommandAttributes {
- /**
- * The integer indicating the number of changes you want to roll back
- */
- value: number;
+ /**
+ * The integer indicating the number of changes you want to roll back
+ */
+ value: number;
}
diff --git a/src/models/commands/rollback-count-sql-command-attributes.model.ts b/src/models/commands/rollback-count-sql-command-attributes.model.ts
index 70bfd0d..7b543d7 100644
--- a/src/models/commands/rollback-count-sql-command-attributes.model.ts
+++ b/src/models/commands/rollback-count-sql-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface RollbackCountSQLCommandAttributes {
- /**
- * The integer indicating the number of changes you want to rollback
- */
- value: number;
+ /**
+ * The integer indicating the number of changes you want to rollback
+ */
+ value: number;
}
diff --git a/src/models/commands/rollback-sql-command-attributes.model.ts b/src/models/commands/rollback-sql-command-attributes.model.ts
index 2cb3759..fb312d7 100644
--- a/src/models/commands/rollback-sql-command-attributes.model.ts
+++ b/src/models/commands/rollback-sql-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface RollbackSQLCommandAttributes {
- /**
- * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
- */
- tag: string;
+ /**
+ * The tag you can add to changesets to determine which changesets in the changelog to evaluate based on their tags.
+ */
+ tag: string;
}
diff --git a/src/models/commands/rollback-to-date-command-attributes.model.ts b/src/models/commands/rollback-to-date-command-attributes.model.ts
index 0ffc86a..8dbc4b0 100644
--- a/src/models/commands/rollback-to-date-command-attributes.model.ts
+++ b/src/models/commands/rollback-to-date-command-attributes.model.ts
@@ -1,7 +1,7 @@
export interface RollbackToDateCommandAttributes {
- /**
- * The date and time your database rolls back to.
- * The date format is YYYY-MM-DD HH:MM:SS or YYYY-MM-DD'T'HH:MM:SS, however, it is possible to indicate the date or time only.
- */
- date: string;
+ /**
+ * The date and time your database rolls back to.
+ * The date format is YYYY-MM-DD HH:MM:SS or YYYY-MM-DD'T'HH:MM:SS, however, it is possible to indicate the date or time only.
+ */
+ date: string;
}
diff --git a/src/models/commands/rollback-to-date-sql-command-attributes.model.ts b/src/models/commands/rollback-to-date-sql-command-attributes.model.ts
index 974c35a..92431dc 100644
--- a/src/models/commands/rollback-to-date-sql-command-attributes.model.ts
+++ b/src/models/commands/rollback-to-date-sql-command-attributes.model.ts
@@ -1,7 +1,7 @@
export interface RollbackToDateSQLCommandAttributes {
- /**
- * The date and time your database rolls back to.
- * The date format is YYYY-MM-DD HH:MM:SS or YYYY-MM-DD'T'HH:MM:SS, however, it is possible to indicate the date or time only.
- */
- date: string;
+ /**
+ * The date and time your database rolls back to.
+ * The date format is YYYY-MM-DD HH:MM:SS or YYYY-MM-DD'T'HH:MM:SS, however, it is possible to indicate the date or time only.
+ */
+ date: string;
}
diff --git a/src/models/commands/snapshot-command-attributes.model.ts b/src/models/commands/snapshot-command-attributes.model.ts
index c6178ca..ed75fdb 100644
--- a/src/models/commands/snapshot-command-attributes.model.ts
+++ b/src/models/commands/snapshot-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface SnapshotCommandAttributes {
- /**
- * Creates a JSON or YAML file that represents the current state of the database.
- */
- snapshotFormat?: string;
+ /**
+ * Creates a JSON or YAML file that represents the current state of the database.
+ */
+ snapshotFormat?: string;
}
diff --git a/src/models/commands/snapshot-reference-command-attributes.model.ts b/src/models/commands/snapshot-reference-command-attributes.model.ts
index b248be8..9a97655 100644
--- a/src/models/commands/snapshot-reference-command-attributes.model.ts
+++ b/src/models/commands/snapshot-reference-command-attributes.model.ts
@@ -1,6 +1,6 @@
export interface SnapshotReferenceCommandAttributes {
- /**
- * Creates a JSON or YAML file that represents the current state of the database.
- */
- snapshotFormat?: string;
+ /**
+ * Creates a JSON or YAML file that represents the current state of the database.
+ */
+ snapshotFormat?: string;
}
diff --git a/src/models/commands/substitution-params.model.ts b/src/models/commands/substitution-params.model.ts
new file mode 100644
index 0000000..c9a4b37
--- /dev/null
+++ b/src/models/commands/substitution-params.model.ts
@@ -0,0 +1,13 @@
+export interface ParamsModel {
+ [key: string]: any;
+}
+
+export type SubstitutionParamsModel = ParamsModel;
+
+type HasSubstitutionParams = {
+ substitutionParams: SubstitutionParamsModel;
+};
+
+export type WithSubstitutionParams = HasSubstitutionParams & T;
+
+export type WithOptionalSubstitutionParams