@alifar/dbver
v1.0.8
Published
Migrate postgresql database based on the files
Downloads
20
Maintainers
Readme
Database versioning and migration based on the files that you specified.
Currently works for PostgreSQL.
Important Notes
- 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.
- 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:
- Create the folder with name version in the root of your project
- 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.
- 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
- 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');
- Now you can run script each time the new version file add to the project
npm run-script mig