Description
We have a migration command which migrate DB: npm run migrate
. Underneath it calls built-in sequelize command https://sequelize.org/master/manual/migrations.html.
At the moment when we run this script on DEV or PROD we have to pass several environment variables DB_USERNAME
, DB_PASSWORD
, DB_NAME
and DB_HOST
. Though we already have env variable which defines DB connection settings using env variable DATABASE_URL
with the value which looks like postgres://postgres:postgres@localhost:5432/postgres
.
We don't want to provide separate values DB_USERNAME
, DB_PASSWORD
, DB_NAME
and DB_HOST
instead, we would like to update this config so it:
-
don't use
DB_USERNAME
,DB_PASSWORD
,DB_NAME
andDB_HOST
anymore -
parses the value inside
DATABASE_URL
and split it into value required by thesequelize
: -
It should be done for all envs:
development
,test
,production
- keep default values for
development
andtest
environments, but not forproduction
- keep default values for
-
make sure that migration script works only by setting
DATABASE_URL