0

I am building a nodejs API with PostgreSQL & Sequilize. My client gave me a .sql file which has been exported from dbdiagram.io.

Is it possible to generate all my models base on .sql file ?

or do I have to do it all manually ?

Nicks
  • 724
  • 3
  • 14
  • 31

1 Answers1

1

Sequelize-auto can automatically create model file (its a npm package).

You need to have a database created using the SQL file and then use sequelize-auto.

It automatically generate models for SequelizeJS via the command line.

Installation:

npm install -g sequelize-auto

Using command line :

sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres

Sequelize-auto npm link

Prabhjot Singh Kainth
  • 1,831
  • 2
  • 18
  • 26
  • thanks, but got an error connection.query(...).on is not a function – Nicks Mar 21 '20 at 12:03
  • there is real code, I simply create a table manually then try the command line. I endup manually create each model. – Nicks Mar 23 '20 at 13:16