Context
A multi-tenant B2B SaaS (one schema per tenant plus a central control schema) running development, staging and production on VMs provisioned by hand over several years. The goal was to move all three environments to another cloud provider with a repeatable process, without interrupting active tenants.
Problem
- Drift between environments: different runtime versions and environment variables.
- Manual provisioning, with no script or runbook.
- The newer MySQL default authentication plugin was incompatible with the legacy PDO driver, and the connection failed in every freshly built environment.
What I did
- Audited all three environments (resources, services, databases, variables) and compared them with the target design, including database and runtime tuning.
- Traced the root cause to the authentication plugin; recreating the user with the legacy plugin became a mandatory runbook step.
- Migrated staging, then development, then production, validating each stage. Static IP, security groups and SSL through a reverse proxy in every environment.
- Second phase: files and database moved off the application instances into object storage and a managed database, with smaller instances.
Result
Three environments migrated with no tenant data loss and a documented, repeatable runbook. The second phase lowered the monthly cost, with an estimated payback under two months.