Back to the portfolio

Notes

How I migrated the HR Hub to Google Cloud

Miguel Vaz · November 2026

At Enviagora, I led the migration of the HR Hub to Google Cloud. It's a production system that holds people's data. This piece covers the decisions and the cutover protocol. Data volume, table names and the exact runbook are left out because they're internal.

The problem

In a production database migration, two mistakes are expensive. One is data that arrives different and nobody notices: a missing record, a date in the wrong time zone, a truncated string. The other is a downtime window that keeps stretching because, halfway through, nobody is sure you can still go back.

Both show up when decisions that should have been tested earlier get pushed to cutover day. The work was moving those decisions out of that day and into code, a rehearsal and written checks.

The constraint

HR data is personal data, and Brazil's data protection law (LGPD) applies to it. That rules out a few shortcuts that solve today's problem and leave a door open: a database with a public IP and an allowlist, a service account key stored as a CI secret, deploying straight from a branch to production. The new infrastructure had to close those doors from the start, not in a second phase.

The decision: the whole target in Terraform

I run every project on Google Cloud with Terraform, and the HR Hub went the same way. The target was declared in code:

Cloud Run
Services run as containers, with no servers to manage. A new version is a new image, and going back means pointing at the previous one.
Cloud SQL with a private IP
The PostgreSQL database has no address on the internet. Only things inside the private network can reach it, so a leaked password alone isn't enough to connect.
Secret Manager
Passwords and keys stay out of the code and out of loose pipeline variables. The service reads a secret when it needs it, and access to that secret has its own permission.
Load Balancer and Cloud DNS
Public traffic enters through a single point, and DNS is code too. Changing the system's address means changing a reviewed file, not clicking through a console.

With everything in Terraform, infrastructure goes through the same review flow as application code. That helps with the cutover: with the infrastructure written down, comparing the declared configuration of QA and production becomes a matter of reading code. That comparison shows what was declared differently. It doesn't replace checking the environment that is actually running.

Deploys with no static key, and with approval

CI/CD runs on GitHub Actions and authenticates to Google Cloud through Workload Identity Federation. On each run, GitHub issues a short-lived token, and Google exchanges it for a temporary credential with that pipeline's permissions. There's no service account JSON file stored as a secret. With no long-lived key, there's no key to leak, to rotate every few months or to forget in a fork.

The pipeline also runs secret scanning, and production deploys only go out with approval. That gate separates two things that often get mixed up: code that passed review, and permission to change production. The merge proves the first. The second is a separate decision, made by a person.

The cutover protocol

the cutover, in order

  1. Full rehearsal in QA
  2. Row counts and checksums
  3. ~45 min cutover
  4. Rollback ready

1. Full rehearsal in QA

The whole migration runs first in a QA environment, start to finish, with the same steps that will run in production. The rehearsal makes it possible to find mistakes before they affect production. It's also where you find out, ahead of time, how long the cutover takes. Without it, the length of the maintenance window is a guess.

2. Validation by row counts and checksums

Row counts catch what's missing or extra. Checksums catch what arrived changed even when the count is right, like a field in a different character encoding or a rounded value. Together they help answer the question that decides when the cutover is done: is what's in the target what was in the source?

The acceptance criteria have to be written down before the cutover starts. Deciding on the spot whether a difference is acceptable, with the system down and people waiting, is exactly the decision the rehearsal exists to avoid.

3. A cutover of about 45 minutes

The production cutover took about 45 minutes, following the steps that had already run in the rehearsal.

4. Rollback ready

The way back was prepared before the cutover began. A rollback that only gets thought about once something breaks doesn't really exist: someone ends up improvising while the system is down.

What this protocol doesn't prove

Row counts and checksums help verify the integrity of the data being compared, and how strong that check is depends on what goes into the comparison. They don't prove the application behaves the same in the new environment. That depends on the application's own tests, and the QA rehearsal only covers what QA reproduces. If QA doesn't have the volume or the quirks of real data, neither does the rehearsal.

The 45 minutes apply to this cutover, with this database. They're not a rule for the next migration. What carries over is the protocol: rehearse the whole thing, write the checks before you start and have the way back ready.

After the migration

I'm now part of the team building EnviaMind, Enviagora's single platform for HR, operations, the gatehouse, finance and leadership. It sits on the same foundation as the Hub: Terraform, Cloud Run, private-IP Cloud SQL and CI/CD with Workload Identity Federation, in a monorepo with about 20 systems imported with their history. Data lives in PostgreSQL in layers (raw, trusted and refined), with a universal person key, RLS and server-side RBAC.

Where the facts come from

Everything in this piece is also on my public LinkedIn profile (November 2026). There's no client data, no personal data and no internal Enviagora detail. The explanations of what each piece guarantees are my own.