@karmadata/kdapi-snapshot

Provides easy way to save the state of a database, and later apply it either on the same database or elsewhere. These two functions will be the building blocks of other software, such as version control and deployment.

Usage no npm install needed!

<script type="module">
  import karmadataKdapiSnapshot from 'https://cdn.skypack.dev/@karmadata/kdapi-snapshot';
</script>

README

kdapi-snapshot - Takes a snapshot of KDAPI views and metadata, or applies the snapshot onto a database

Provides easy way to save the state of a database, and later apply it either on the same database or elsewhere. These two functions will be the building blocks of other software, such as version control and deployment.

snapshot(conn, metaschema, viewschemas)

This function exports metadata from metaschema, and views from viewschemas, and returns a snapshot POJO of these JSON/SQL, that can be saved as files or elsewhere

applySnapshot(conn, metaschema, snapshotStructure)

This function applies a snapshot onto the destination database

Architecture

The functions provided by this utility are meant to be very generic. For example, users are expected to perform their own transformations of JSON / SQL if the source database and destination database use different schemas. This simplicity allows kdapi-snapshot to be a robust building block for other tools to consume.

Other supporting functions

dryrun(conn, metaschema, snapshotStructure)

This function has the same signature as applySnapshot, but does not actually run any query. Instead it outputs to console the actions that would be taken.