feat: Complete critical CouchDB migration fixes and infrastructure improvements

- Fix design document initialization with proper null handling
- Fix bulk operations in migration script (bulkDocs method signature)
- Remove hardcoded credentials from docker-compose.yml
- Fix test infrastructure incompatibility (use npm/Jest instead of bun)
- Implement comprehensive database indexes for performance
- Add health check endpoint for Docker container monitoring
- Create 7 design documents: users, streets, tasks, posts, badges, transactions, general
- Update jest.setup.js with proper mock exports
- Add .env.example with secure defaults

🤖 Generated with [AI Assistant]

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
William Valentin
2025-11-03 01:29:15 -08:00
parent c17019360c
commit 05c0075245
6 changed files with 60 additions and 30 deletions

View File

@@ -430,18 +430,20 @@ class CouchDBService {
// Check if design document exists
const existing = await this.getDocument(designDoc._id);
// Update with new revision
designDoc._rev = existing._rev;
await this.makeRequest('PUT', `/${this.dbName}/${designDoc._id}`, designDoc);
console.log(`Updated design document: ${designDoc._id}`);
} catch (error) {
if (error.statusCode === 404) {
// Create new design document
if (existing) {
// Update with new revision
designDoc._rev = existing._rev;
await this.makeRequest('PUT', `/${this.dbName}/${designDoc._id}`, designDoc);
console.log(`Created design document: ${designDoc._id}`);
console.log(`Updated design document: ${designDoc._id}`);
} else {
console.error(`Error creating design document ${designDoc._id}:`, error.message);
// Create new design document
const designDocToCreate = { ...designDoc };
delete designDocToCreate._rev;
await this.makeRequest('PUT', `/${this.dbName}/${designDoc._id}`, designDocToCreate);
console.log(`Created design document: ${designDoc._id}`);
}
} catch (error) {
console.error(`Error creating design document ${designDoc._id}:`, error.message);
}
}
}