generate sequilize models from sql file

1.3k views Asked by At

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 ?

1

There are 1 answers

2
Prabhjot Singh Kainth On

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