Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with sequelize db:migrate and postgres

i'm a beginner and i'm trying to deploy a back-end application. I'm using an aws EC2 with ubuntu server and the problem is as follows. in the application on my machine the command "yarn sequelize db: migrate" runs normally, executes the migrations and creates the tables. but not on the server. I already changed the environment variables, even put the information directly in the code, even so it does not run the migrations. the most it does is: [email protected]: ~ / app / server $ yarn sequelize db: migrate yarn run v1.22.4 $ /home/deploy/app/server/node_modules/.bin/sequelize db: migrate

Sequelize CLI [Node: 14.4.0, CLI: 5.5.1, ORM: 5.21.6]

Loaded configuration file "src / config / database.js". Done in 0.54s.

It is as if I did not enter the migrations folder for any reason

i'm using postgres on docker image.

like image 508
Thiago Rossato Avatar asked Feb 06 '26 10:02

Thiago Rossato


1 Answers

TL;DR: try to use the latest version for all the dependencies for sequelize-cli, as shown in the last code block of this response.

I am not 100% sure if this is the same issue I encountered. But I have been stuck in a similar situation for 2 days. Basically when I run "npx sequelize db:migrate", it will show the following,

Sequelize CLI [Node: 14.4.0, CLI: 5.5.1, ORM: 5.21.6]

Loaded configuration file "src / config / database.js".
Using environment "development".

Then it just stopped there! I dived deep into the sequelize-cli library and put some console log statements in to see what's failing. Eventually I found that somehow it's failing in

return sequelize.authenticate().then(() => { 

this line in the /sequelize-cli/lib/core/migrator.js

Eventually, it got me wondering if this is an external dependency issue. Then I use the latest dependencies, as following in my package.json

"dependencies": {
    "pg": "^8.2.1",
    "sequelize": "^5.21.13",
    "sequelize-cli": "^5.5.1"
},

I realized that I was previously using "pg": "^7.18.2". Then this fixed the issue for me.

like image 82
H.T. Kong Avatar answered Feb 09 '26 01:02

H.T. Kong