@alifar/dbver

1.0.8 • Public • Published

Database versioning and migration based on the files that you specified.

Currently works for PostgreSQL.

Important Notes

  1. There must be a 'version' folder in root of the project and all sql files must be placed in. The standard format for the naming can be: version-001.sql, version-002.sql, etc.
  2. you must set all postgres connection string variables as .env file in root of the project. These constant variables are:
  • POSTGRES_SERVER
  • POSTGRES_PORT
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_DB

All you have to do is require the module

require('@alifar/dbver');

More Detail

In order to use this module:

  1. Create the folder with name version in the root of your project Add "version" folder to the root
  2. Create the sql versioning file with the pattern version-001.sql, version-002.sql, ... under the version folder. Each file contains sql statement steps during the project progress. Each statement in each file must be end with semicolon ';' and it is important to follow this rule. Add semicolon at the end of each statement
  3. you can add the .env file in root of project and all POstgreSQL configurations must be set there. It is recommanded that use dotenv module for managing the environment variables. The keys are as follows:
  • POSTGRES_SERVER
  • POSTGRES_PORT
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_DB Add environment variables
  1. You can add the code bellow on seperate file like versioning.js and add the command at scripts section in package.json file.
require('@alifar/dbver');

Add to scripts section in package.json

  1. Now you can run script each time the new version file add to the project
npm run-script mig

Package Sidebar

Install

npm i @alifar/dbver

Weekly Downloads

6

Version

1.0.8

License

ISC

Unpacked Size

121 kB

Total Files

11

Last publish

Collaborators

  • alifar