versiondb

3.0.0 • Public • Published

Version DB

An tool for maintaining the versioned schemas in a postgresql database.

Build Status

How it works

Version DB creates a single table (versiondb.version) in the target database that tracks which version of each product's database schema resides in the database. Every time it is run, it checks what version of a product's database schema is on the database, checks the schema file, and runs all of the scripts required to bring the database schema up to the latest version.

If a product does not exist in the database, all of the scripts will be run on the database to create a schema that is the latest version.

Installation

npm install -g versiondb

Usage

To check what schemas are currently installed on a database

versiondb ls

To run upgrade scripts for a product

versiondb run path/to/my/awesome/product/schema.yaml

Schema Files

Schema files are written in YAML.

product: my-product
 
versions:
  version: "1.0"
    tasks:
      name: Create tables
        script: 1.0/tables.sql
      name: Create functions
        script: 1.0/functions.sql
      name: Create users
        script: 1.0/users.sql
 
  version: "1.1"
    tasks:
      name: Tables and functions that support the new wizbang feature
        script: 1.1/wizbang.sql
      name: Tables and functions that support the new foobar feature
        script: 1.1/foobar.sql

The scripts are referenced relative the schema file. Versions are considered ordered by the order that they are in the schema file. (E.g., versiondb does not do semver ordering or alphabetical ordering. It considers one version to be after another version if it appears lower in the schema file.)

/versiondb/

    Package Sidebar

    Install

    npm i versiondb

    Weekly Downloads

    1

    Version

    3.0.0

    License

    MIT

    Last publish

    Collaborators

    • bryanburgers