fix: improve migration error handling to gracefully handle existing tables
This commit is contained in:
parent
bbaf330020
commit
573efea5b5
1 changed files with 5 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue