nodejs-express-mysql icon indicating copy to clipboard operation
nodejs-express-mysql copied to clipboard

Automatic database and table creation

Open Breno-Corsi opened this issue 2 months ago • 0 comments

Summary

This Pull Request introduces a new file called db.init.js inside the app/config/ directory.

The purpose of this file is to initialize the database and create all tables automatically using Sequelize.
With this addition, users can easily set up the project’s database without having to manually create it via MySQL commands.


Details

  • Added a new file: app/config/db.init.js
  • This script uses the Sequelize ORM to define table constraints.
  • It creates the configured database (if it does not exist) and synchronizes all defined models to generate the required tables.

Usage

To initialize the database, simply run the following command:

node ./app/config/db.init.js

You should see in your terminal something like this:

Database "database_name" created successfully!
All tables created/updated successfully in database "database_name"!

Feedback

Looking forward to your feedback!
Please let me know if any adjustments are needed.

Breno-Corsi avatar Oct 10 '25 00:10 Breno-Corsi