Skip to content

[$30] Use existent env variable during DB migration #634

Open
@maxceem

Description

@maxceem

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 and DB_HOST anymore

  • parses the value inside DATABASE_URL and split it into value required by the sequelize:

    image

  • It should be done for all envs: development, test, production

    • keep default values for development and test environments, but not for production
  • make sure that migration script works only by setting DATABASE_URL

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions