# Complete Migration Automation Guide **Date**: 2025-01-27 **Purpose**: Complete guide for automated project migrations **Status**: Complete --- ## Overview This guide provides complete automation for migrating projects to shared infrastructure, monorepos, and services. --- ## DBIS Monorepo Migration ### Automated Migration #### Single Project ```bash ./scripts/dbis/automate-dbis-migration.sh dbis_core dbis_monorepo packages ``` **What it does**: - Copies project to monorepo - Updates package.json name - Creates migration notes - Provides next steps #### All Projects ```bash ./scripts/dbis/migrate-all-dbis-projects.sh dbis_monorepo ``` **What it does**: - Migrates all DBIS projects - Creates migration notes for each - Provides comprehensive next steps ### Manual Steps After Automation 1. **Update Dependencies** ```bash cd dbis_monorepo/packages/dbis_core # Edit package.json to use @dbis/* and @workspace/* packages ``` 2. **Update Imports** ```typescript // Before import { User } from '../types'; // After import { User } from '@dbis/shared-types'; ``` 3. **Test Build** ```bash cd dbis_monorepo pnpm install pnpm build ``` 4. **Test Tests** ```bash pnpm test ``` --- ## Infrastructure Migrations ### Monitoring Migration ```bash ./scripts/migration/migrate-to-monitoring.sh my-project production ``` ### Kubernetes Migration ```bash ./scripts/migration/migrate-to-k8s.sh my-project ``` ### API Gateway Migration ```bash ./scripts/migration/migrate-to-api-gateway.sh my-service http://my-service:8080 ``` ### Shared Packages Migration ```bash ./scripts/migration/migrate-to-shared-packages.sh ``` ### Terraform Migration ```bash ./scripts/migration/migrate-terraform.sh ``` --- ## Migration Workflow ### Pre-Migration 1. Review migration guide 2. Backup current state 3. Set up test environment 4. Review dependencies ### Migration 1. Run automation script 2. Review generated files 3. Update configurations 4. Test in isolation ### Post-Migration 1. Verify functionality 2. Update documentation 3. Deploy to staging 4. Monitor metrics 5. Deploy to production --- ## Verification Checklist ### After Each Migration - [ ] Build successful - [ ] Tests passing - [ ] Dependencies resolved - [ ] Imports updated - [ ] Configuration correct - [ ] Documentation updated ### Before Production - [ ] Staging deployment successful - [ ] Integration tests passing - [ ] Performance acceptable - [ ] Monitoring configured - [ ] Rollback plan ready --- ## Troubleshooting ### Common Issues #### Build Failures - Check dependencies - Verify TypeScript configuration - Review import paths - Check for missing files #### Test Failures - Update test configurations - Fix import paths - Update mocks - Review test data #### Dependency Issues - Verify workspace protocol - Check package versions - Review peer dependencies - Clear node_modules and reinstall --- ## Best Practices ### Automation - Use provided scripts - Review generated code - Test thoroughly - Document custom changes ### Migration - Migrate incrementally - Test each step - Keep backups - Have rollback plan ### Verification - Test in isolation first - Test integrations - Monitor metrics - Gather feedback --- **Last Updated**: 2025-01-27