feat(db): add environments.machine_size (SUPER-3135)

Merged
HA
4d ago
+17834-0

Links

  • Linear: SUPER-3135 — bake default machine sizes into environments
  • Code that uses it: stacked PR on superset/cloud-environment-onboarding (opened right after this one)

Summary

  • Adds a nullable environments.machine_size text column: the size a workspace boots at when its create names none. null means the organization's default, which is every existing row.
  • Migration-only, per packages/trpc/AGENTS.md rule 10 and the db-migrations checklist, so the API change can be reverted on its own.

Migration safety (db-migrations checklist)

  • Statement: ALTER TABLE "environments" ADD COLUMN "machine_size" text; — no default and nullable, so Postgres only updates the table's metadata. There is no rewrite and no scan, just a brief ACCESS EXCLUSIVE lock on environments.
  • Size: environments is about 176 kB / 229 rows (measured on this workspace's Neon branch, which was copied from production today). It is not one of the hot tables (auth.*, automation_events, ingest.webhook_events), and no job holds it open.
  • Lock order: a single table, with no foreign keys added.
  • Not rehearsed under load: nothing in it locks a hot table or rewrites or scans a large one, so the size and lock checks are enough (per the skill).
  • Generated with drizzle-kit generate, not hand-edited. The snapshot's prevId chains to 0192.
  • Applied with PGOPTIONS="-c lock_timeout=5s -c statement_timeout=60s" bunx drizzle-kit migrate, to this workspace's own Neon branch only (br-misty-firefly…, a non-default child branch).

Known deviation

  • The checklist asks for no tRPC output change in a migration PR. environment.list / get / create / update select every column, so their output gains machineSize: null once this lands. That's additive, and no client reads it until the stacked PR ships.

Rollout / Rollback

  • Order: merge and deploy this first. The stacked code PR reads and writes the column.
  • Rollback: nothing reads the column until the code PR lands, so a revert is a plain DROP COLUMN migration if it's ever needed.

Summary by cubic

Adds a nullable environments.machine_size column that stores the machine size a workspace boots at when its create names none; null means the organization's default, which is every existing row. This is migration-only — the API change that reads and writes the column ships in the stacked PR on superset/cloud-environment-onboarding, so this migration can be reverted on its own.

  • No default and nullable, so Postgres only updates the table's metadata on environments (~229 rows, not a hot table); no rewrite or scan, just a brief lock.
  • Generated with drizzle-kit generate and applied only to this workspace's Neon branch.
  • Rollback is a plain DROP COLUMN migration since nothing reads the column yet.

Known deviation

  • environment.list / get / create / update select every column, so their output gains machineSize: null once this lands; additive, and no client reads it until the stacked PR ships.

Summary by CodeRabbit

  • New Features
    • Environments can now store a machine size for workspace startup. If none is specified, the organization default is used.