Add logging for model synchronization and cache handling in syncDatabase.js
Enhance sequelize.js by adding a console log to indicate when models are being synced without constraints. Update syncDatabase.js to include important notes on caching issues with Node.js ES-Modules and log the model loading process during deployment synchronization.
This commit is contained in:
@@ -478,6 +478,7 @@ const syncModelsAlways = async (models) => {
|
|||||||
try {
|
try {
|
||||||
// constraints: false verhindert, dass Sequelize Foreign Keys automatisch erstellt
|
// constraints: false verhindert, dass Sequelize Foreign Keys automatisch erstellt
|
||||||
// Foreign Keys sollten nur über Migrations verwaltet werden
|
// Foreign Keys sollten nur über Migrations verwaltet werden
|
||||||
|
console.log(` 🔄 Syncing model ${model.name} with constraints: false`);
|
||||||
await model.sync({ alter: true, force: false, constraints: false });
|
await model.sync({ alter: true, force: false, constraints: false });
|
||||||
} finally {
|
} finally {
|
||||||
// Restore VIRTUAL fields after sync
|
// Restore VIRTUAL fields after sync
|
||||||
|
|||||||
@@ -210,6 +210,10 @@ const syncDatabase = async () => {
|
|||||||
// Deployment-Synchronisation (immer Schema-Updates)
|
// Deployment-Synchronisation (immer Schema-Updates)
|
||||||
const syncDatabaseForDeployment = async () => {
|
const syncDatabaseForDeployment = async () => {
|
||||||
try {
|
try {
|
||||||
|
// WICHTIG: Bei Caching-Problemen das Script neu starten
|
||||||
|
// Node.js cached ES-Module, daher müssen Models neu geladen werden
|
||||||
|
console.log('📦 Lade Models neu (Node.js Module-Cache wird verwendet)...');
|
||||||
|
|
||||||
// Zeige den aktuellen Stage an
|
// Zeige den aktuellen Stage an
|
||||||
const currentStage = process.env.STAGE || 'nicht gesetzt';
|
const currentStage = process.env.STAGE || 'nicht gesetzt';
|
||||||
console.log(`🚀 Starte Datenbank-Synchronisation für Deployment (Stage: ${currentStage})`);
|
console.log(`🚀 Starte Datenbank-Synchronisation für Deployment (Stage: ${currentStage})`);
|
||||||
|
|||||||
Reference in New Issue
Block a user