"how to create mysql database with sequelize (nodejs)" Code Answer

1

short answer: sure you can!

here's how i got it done:

//create the sequelize instance, omitting the database-name arg
const sequelize = new sequelize("", "<db_user>", "<db_password>", {
  dialect: "<dialect>"
});

return sequelize.query("create database `<database_name>`;").then(data 
=> {
  // code to run after successful creation.
});

p.s. where to place code would depend on your need. inside an initial migration file worked for me.

By Maciej Gol on May 18 2022

Answers related to “how to create mysql database with sequelize (nodejs)”

Only authorized users can answer the Search term. Please sign in first, or register a free account.