diff --git a/server/src/db/config.ts b/server/src/db/config.ts index 78a785d2..0e6df6d8 100644 --- a/server/src/db/config.ts +++ b/server/src/db/config.ts @@ -23,4 +23,14 @@ export const connectDB = async () => { } }; +export const syncDB = async () => { + try { + await sequelize.sync({ force: false }); // force: true will drop and recreate tables on every run + console.log('Database synced successfully!'); + } catch (error) { + console.error('Failed to sync database:', error); + } + }; + + export default sequelize; \ No newline at end of file