Files
adopt-a-street/scripts/migrate-production.js
William Valentin 5aca521c52 feat: Complete CouchDB migration and Docker configuration
- Add comprehensive CouchDB setup and configuration
- Update Docker files for CouchDB compatibility
- Create Kubernetes manifests for CouchDB deployment
- Add migration scripts and documentation
- Update seeding scripts to support both CouchDB and MongoDB
- Add docker-compose for local development
- Create comprehensive setup and deployment guides

🤖 Generated with [AI Assistant]

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
2025-11-01 13:32:39 -07:00

62 lines
2.2 KiB
JavaScript

#!/usr/bin/env node
const CouchDBSetup = require('./setup-couchdb');
const MongoToCouchMigrator = require('./migrate-to-couchdb');
class ProductionMigration {
constructor() {
this.setup = new CouchDBSetup();
this.migrator = new MongoToCouchMigrator();
}
async run() {
console.log('🚀 Starting production migration to CouchDB...\n');
try {
// Step 1: Setup CouchDB
console.log('=== Step 1: Setting up CouchDB ===');
await this.setup.initialize();
await this.setup.createDatabase();
await this.setup.createIndexes();
await this.setup.createSecurityDocument();
await this.setup.seedBadges();
console.log('✅ CouchDB setup completed\n');
// Step 2: Migrate data from MongoDB
console.log('=== Step 2: Migrating data from MongoDB ===');
await this.migrator.runMigration();
console.log('✅ Data migration completed\n');
// Step 3: Final verification
console.log('=== Step 3: Final verification ===');
await this.setup.verifySetup();
console.log('✅ Verification completed\n');
console.log('🎉 Production migration completed successfully!');
console.log('\n📋 Next steps:');
console.log('1. Update your application configuration to use CouchDB');
console.log('2. Deploy the updated application');
console.log('3. Monitor the application for any issues');
console.log('4. Keep MongoDB backup for a rollback period');
} catch (error) {
console.error('\n❌ Production migration failed:', error.message);
console.error('\n📋 Troubleshooting steps:');
console.error('1. Check MongoDB connection and data integrity');
console.error('2. Verify CouchDB is running and accessible');
console.error('3. Check environment variables and credentials');
console.error('4. Review migration logs for specific errors');
console.error('5. Consider running migration in smaller batches');
process.exit(1);
}
}
}
// Run migration if called directly
if (require.main === module) {
const migration = new ProductionMigration();
migration.run().catch(console.error);
}
module.exports = ProductionMigration;