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') });
|
migrate(db, { migrationsFolder: path.join(process.cwd(), 'drizzle') });
|
||||||
console.log('✅ Database migrations completed');
|
console.log('✅ Database migrations completed');
|
||||||
} catch (error) {
|
} 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);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
if (errorMessage.includes('already exists')) {
|
const causeMessage = error instanceof Error && error.cause ? String(error.cause) : '';
|
||||||
console.log('⚠️ Database tables already exist, skipping migrations');
|
|
||||||
|
if (errorMessage.includes('already exists') || causeMessage.includes('already exists')) {
|
||||||
|
console.log('ℹ️ Database schema already up to date');
|
||||||
} else {
|
} else {
|
||||||
console.error('❌ Migration failed:', error);
|
console.error('❌ Migration failed:', error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue