fix: improve migration error handling to gracefully handle existing tables

This commit is contained in:
Marko Djordjevic 2026-02-16 19:43:32 +01:00
parent bbaf330020
commit 573efea5b5

View file

@ -24,10 +24,12 @@ if (!isBuildTime) {
migrate(db, { migrationsFolder: path.join(process.cwd(), 'drizzle') });
console.log('✅ Database migrations completed');
} catch (error) {
// Check if error is about table already existing
// Check if error is about table already existing - this is expected when container restarts with existing volume
const errorMessage = error instanceof Error ? error.message : String(error);
if (errorMessage.includes('already exists')) {
console.log('⚠️ Database tables already exist, skipping migrations');
const causeMessage = error instanceof Error && error.cause ? String(error.cause) : '';
if (errorMessage.includes('already exists') || causeMessage.includes('already exists')) {
console.log(' Database schema already up to date');
} else {
console.error('❌ Migration failed:', error);
throw error;