0

I would like to change my DB password in production in Sequelize.

So I would like to run a script that changes my DB password for connection, and next time I preform application to update it does not get overridden :)

Here is my for sample migration.config.json

{
  "development": {
    "username": "postgres",
    "password": "postgres",
    "database": "db",
    "host": "localhost",
    "dialect": "postgres",
    "logging": false,
    "seederStorage": "sequelize",
    "operatorsAliases": false
  },
  "test": {
    "username": "test",
    "password": "stest",
    "database": "test_db",
    "host": "127.0.0.1",
    "dialect": "postgres",
    "logging": false,
    "seederStorage": "sequelize",
    "operatorsAliases": false
  },
  "production": {
    "username": "prod",
    "password": "prod",
    "database": "db_prod",
    "host": "127.0.0.1",
    "dialect": "postgres",
    "seederStorage": "sequelize",
    "operatorsAliases": false
  }
}

Do I need for example to create bash script that will do following:

  1. Execute command in psql to change DB password
  2. edit migation.config.json with new value

or is there some other steps how to do this ??

Loki
  • 1,064
  • 2
  • 26
  • 55

1 Answers1

0

So I have managed to change password on production with following steps:

Replaced Database related variables in migration.config with ENV variables

Created node script that will export new ENV variable for Databases, Change password in database with psql with command:

ALTER USER user_name WITH PASSWORD 'new_password';

Restarted Node server with pm2.

Loki
  • 1,064
  • 2
  • 26
  • 55