Deployments create a mixed-version interval
During rollout, old readers, new readers, old writers and new writers may run simultaneously. Expand-contract first adds backward-compatible schema, then deploys compatible code, dual-writes or backfills, switches reads, and removes obsolete state only after old binaries are gone.
Validation and enforcement are separate operations
Large-table rewrites and strong locks belong in an explicit migration plan. A common PostgreSQL pattern adds a constraint without validating existing rows, backfills in bounded batches, validates, then enforces the invariant. Exact lock behavior must be checked for the deployed PostgreSQL version and DDL form.