PR #9706 review: environments.machine_size migration
Summary
Adds a nullable environments.machine_size text column: the machine size a workspace boots at when its create call names none. null (every existing row) means the organization's default. The PR has only the migration. The code that reads and writes the column comes in a stacked PR, as packages/trpc/AGENTS.md rule 10 asks.
Verdict
Looks good. It is a metadata-only ADD COLUMN on a small, cold table. The generated files match the schema, it applies cleanly with production lock settings, and CI is green.
Findings
Nothing blocking. One optional nit:
- Nit,
packages/db/src/schema/schema.ts:828:machineSizeis a plaintext, so Drizzle infersstring | null. The stacked PR must then narrow it withisMachineSizeon every read. Optional fix:text("machine_size").$type<MachineSize>()(from@superset/shared/billing, which@superset/dbalready depends on). This changes no SQL. It is fine to skip this:v2_workspaces.machine_size(:987) andautomations.machine_size(:1760) are untypedtextas well, and a narrowed type can hide stale values after a size is removed from the offer.
Things I checked that are correct:
- SQL is
ALTER TABLE "environments" ADD COLUMN "machine_size" text;. It has no default and no NOT NULL, so Postgres changes only metadata (no rewrite and no scan). - The
0193_snapshot.jsonprevIdequals the 0192 snapshotid(833173b8…). The 0193 snapshot is identical to 0192 except for the new column, so nothing was hand-edited and nothing unrelated changed. drizzle-kit generateat the PR head reports "No schema changes", so the schema and snapshot agree.- It touches one table and adds no FK or index, so the lock order rule (3) does not apply.
environmentsis not a hot table (rule 4). - The known deviation (
environment.*outputs gainmachineSize: nullbecause the proceduresselect()every column) is additive and safe for released clients.
Evidence
Surface: DB migration only (no UI, CLI or API code changed). I applied it to this review workspace's own Neon branch (br-bold-heart…, endpoint ep-odd-leaf, a child of production). I did not use a shared or production database.
Table size on the production-child branch:
environments | 176 kB | 226 rows
Schema drift check at the PR head:
$ bunx drizzle-kit generate --name=probe No schema changes, nothing to migrate 😴
Apply with the production deploy settings:
$ PGOPTIONS="-c lock_timeout=5s -c statement_timeout=60s" bunx drizzle-kit migrate [✓] migrations applied successfully! (1.75 s wall clock, including the CLI start-up) $ \d environments machine_size | text | | | drizzle.__drizzle_migrations: 196 → 197 rows environments: 230 rows, 0 with machine_size set (all null = org default)
I did not rehearse under load (pgbench). That matches the skill: the table is small and not hot.
Questions for the author
- Will the stacked PR check
environments.machine_sizeagainstorganizationMachineSizes()at workspace create time, as well as on write? If an org's plan later drops a size, a stored value can become invalid. What should happen then: fall back to the org default, or fail? - Do you want
$type<MachineSize>()here, or do you prefer to keep the threemachine_sizecolumns the same (plaintext)?
Test / CI notes
All at head 2b365bdee2a289212435e8180d477d0ddf293472:
- GitHub checks: Lint, Typecheck, Test, Sherif, Vale, Version Sync, Build CLI, Create/Deploy Database (Neon), Deploy API/Web/Marketing/Docs, Page storage integration, CodeRabbit all success. cubic: neutral.
- Locally:
bun run typecheckinpackages/dbandpackages/trpcpass. Thedrizzle-kit generatedrift check passes.drizzle-kit migrateon the workspace Neon branch passes.