Open aobregonmx opened 2 months ago
Workaround My application runs inside PM2 and the environment variables are injected from the ecosystem.config.js configuration file
After creating the .env file with the environment variables, the sequelize-cli db:migrate command ran without errors
I think sequelize-cli can't read environment variables injected by PM2
@aobregonmx I try to run sequelize-cli command in the ec2 instance with inline environment variables but it doesn't work. To resolve the issue i need to set env globally for the current shell session using the command
export <ENV_NAME>=<ENV_VALUE>
<COMMAND_TO_RUN>
Is the sequelize-cli not able to use an inline environment variable.
I think sequelize-cli
runs outside of the PM2 environment and that's why it doesn't read the injected variables. When I have implemented CI
it will carry out the process of creating the .env file as indicated in the comments of the official documentation Environment Variables Management
What you are doing?
npx sequelize-cli db:migrate
command don't read the environment variablesThis command works without problems in my local environment on macOS Sonoma 14.2.1 but when I try to run it in a development environment (PM2 version 5.3.1) it does not work
.sequelizerc
config.cjs
common/config.js
What do you expect to happen?
Get a message similar to the one obtained in my local macOS environment
What is actually happening?
I am getting this message in the terminal, where it is not reading the environment variables and is not creating the models in the database
I tried printing the variables and either way I'm getting undefined
Dialect: postgres Database version: PostgreSQL 12.19 (Ubuntu 12.19-0ubuntu0.20.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.3) 9.4.0, 64-bit Sequelize CLI version: 6.6.2 Sequelize version: 6.37.3 PM2 version: 5.3.1