feat: call setupAssociations() before sync
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Sequelize } from 'sequelize';
|
import { Sequelize } from 'sequelize';
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
|
import setupAssociations from '../models/associations';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const sequelize = new Sequelize(
|
const sequelize = new Sequelize(
|
||||||
@@ -22,6 +23,7 @@ export const connectDB = async () => {
|
|||||||
|
|
||||||
export const syncDB = async () => {
|
export const syncDB = async () => {
|
||||||
try {
|
try {
|
||||||
|
//setupAssociations();
|
||||||
await sequelize.sync({ force: false }); // force: true will drop and recreate tables on every run
|
await sequelize.sync({ force: false }); // force: true will drop and recreate tables on every run
|
||||||
console.log('Database synced successfully!');
|
console.log('Database synced successfully!');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user