Initialize model associations in server setup: Import and invoke setupAssociations to ensure all models share the same instance, preventing EagerLoadingError and enhancing data integrity before loading the app and services.
This commit is contained in:
@@ -3,6 +3,11 @@ import './config/loadEnv.js'; // .env deterministisch laden
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import fs from 'fs';
|
||||
// Assoziationen sofort setzen, bevor app (und damit Services/Router) geladen werden.
|
||||
// So nutzen alle Modelle dieselbe Instanz inkl. Associations (verhindert EagerLoadingError).
|
||||
import setupAssociations from './models/associations.js';
|
||||
setupAssociations();
|
||||
|
||||
import app from './app.js';
|
||||
import { setupWebSocket } from './utils/socket.js';
|
||||
import { syncDatabase } from './utils/syncDatabase.js';
|
||||
|
||||
Reference in New Issue
Block a user