nodejs-express-mysql
nodejs-express-mysql copied to clipboard
Automatic database and table creation
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.