Under development
This is an easy, basic and raw example of HOW to implement ???
- Node 12+
- NPM
- PostgreSQL
- db-migrate package as a global dependency
npm install(... for dev and test)
createdb test_db
createdb test_db_testdb-migrate create migration-for-users-table --sql-file... to the newly created *.sql files.
migrations/sqls/20210811211022-migration-for-users-table-up.sql
CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(50), age integer);migrations/sqls/20210811211022-migration-for-users-table-down.sql
DROP TABLE users;npm run migrate:upThis will run migrations for the dev environment.
If you want to do it in other environment, for example test, you need to have the stage and its configuration data in the database.json file and pass the proper flag.
Sample usage:
db-migrate up --env test npm run devnpm run build
npm start