mysql-database-versioning

1.0.3 • Public • Published

database-manager

This package helps with versioning the database in node.js projects. The .env.sample file has a list of all environment variables required to setup the project.

DBHOST=dbserver host
DBUSER=db user
DBPASSWORD=db password
DBNAME=db name
DBPORT=3306
DB_VERSION_SCRIPT_FOLDER=./scripts/
LOG_LEVELS=DEBUG

After you have the environment variables setup just include database-manager in your script and start versioning. The scripts folder contains a series of .sql files.

This package maintains history of executed scripts in a table inside the database and only executes scripts which have not been executed before.

require('custom-env').env(true);
require('dotenv').config();

const DatabaseManager = require('database-manager');

(async () => {
    var executor = new DatabaseManager();
    await executor.execute_scripts(true); // set false if history table already exists
})();

Project website

https://github.com/hashgit/database-manager

/mysql-database-versioning/

    Package Sidebar

    Install

    npm i mysql-database-versioning

    Weekly Downloads

    2

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    7.51 kB

    Total Files

    7

    Last publish

    Collaborators

    • hashgit