Skip to content

ci(types): guard types.ts generation, and finish migration 350's move - #771

Merged
thinkclay merged 2 commits into
mainfrom
fix/types-generation-guard
Sep 15, 2026
Merged

thinkclay merged 2 commits into
mainfrom
fix/types-generation-guard

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Salvages the parts of #719 that are still true. That PR has been open since
2026-09-09, its issue (#707) closed on 09-10, and main has moved 28 commits
past its base — so most of it is now either redundant or a regression, but the
guard at its centre never landed and is still the only thing standing between
this repo and a repeat of #707.

Taken

scripts/generate-supabase-types.mjs (blink-dev's, unchanged). supabase gen types reports what the database in front of it contains, so pointing it at a
database behind the migrations silently deletes every object added since,
straight over types.ts with no diff to review. The script refuses to run when
the migration list and the applied set disagree, generates in memory, and
refuses to write when a table, view, enum or function would disappear —
--allow-removals for the deliberate case, like migration 344 dropping
core.application_status. supa:generate and the supabase project.json target
now point at it.

Exercised rather than assumed: with no local stack it exits 1 with "Refusing to
generate: could not read the migration list", and types.ts is untouched
afterwards.

The CI halves come too — api-tests.yml regenerates against a fresh
supabase start and fails on a diff, and ci.yml adds expo install --check
for the Expo SDK skew behind #683/#689.

feedback.router.ts moves off .schema('logs'). That one is mine to own:
migration 350 moved user_feedback to core with ALTER TABLE ... SET SCHEMA
and I never swept for readers. These two lines are the last ones left on main —
dormant, since trpc is not in deploy-functions.sh's deploy list any more, but
wrong.

Not taken

packages/supabase/types.ts — redundant. main already carries content_reports,
user_blocks, user_feedback, soft_skills_ratings and profile_import_data.

table-references-exist.test.ts — this is the conflict, and taking it would go
backwards. #719 restores four BASELINE_BROKEN entries that main has since
resolved properly: soft_skills_ratings and profile_import_data exist as of
migration 354 (#658), core.inquiries' routes were deleted (#476), and
profile_completion_nudges' route was retired. The baseline is empty on main and
fails on stale entries, so merging that file would fail the very test it edits.

package.json was applied by hand for the same reason — #719's copy predates
lint:migrations and would have deleted both the script and its call from
lint. Only the supa:generate line is changed here.

Co-Authored-By: blink-dev [email protected]

Supersedes #719.


🤖 Generated with Claude Code

Salvages the parts of #719 that are still true. That PR has been open since
2026-09-09, its issue (#707) closed on 09-10, and `main` has moved 28 commits
past its base — so most of it is now either redundant or a regression, but the
guard at its centre never landed and is still the only thing standing between
this repo and a repeat of #707.

**Taken**

`scripts/generate-supabase-types.mjs` (blink-dev's, unchanged). `supabase gen
types` reports what the database in front of it contains, so pointing it at a
database behind the migrations silently deletes every object added since,
straight over types.ts with no diff to review. The script refuses to run when
the migration list and the applied set disagree, generates in memory, and
refuses to write when a table, view, enum or function would disappear —
`--allow-removals` for the deliberate case, like migration 344 dropping
core.application_status. `supa:generate` and the supabase project.json target
now point at it.

Exercised rather than assumed: with no local stack it exits 1 with "Refusing to
generate: could not read the migration list", and types.ts is untouched
afterwards.

The CI halves come too — api-tests.yml regenerates against a fresh
`supabase start` and fails on a diff, and ci.yml adds `expo install --check`
for the Expo SDK skew behind #683/#689.

`feedback.router.ts` moves off `.schema('logs')`. That one is mine to own:
migration 350 moved `user_feedback` to `core` with `ALTER TABLE ... SET SCHEMA`
and I never swept for readers. These two lines are the last ones left on main —
dormant, since `trpc` is not in deploy-functions.sh's deploy list any more, but
wrong.

**Not taken**

`packages/supabase/types.ts` — redundant. main already carries content_reports,
user_blocks, user_feedback, soft_skills_ratings and profile_import_data.

`table-references-exist.test.ts` — this is the conflict, and taking it would go
backwards. #719 restores four BASELINE_BROKEN entries that main has since
resolved properly: soft_skills_ratings and profile_import_data exist as of
migration 354 (#658), core.inquiries' routes were deleted (#476), and
profile_completion_nudges' route was retired. The baseline is empty on main and
fails on stale entries, so merging that file would fail the very test it edits.

`package.json` was applied by hand for the same reason — #719's copy predates
`lint:migrations` and would have deleted both the script and its call from
`lint`. Only the `supa:generate` line is changed here.

Co-Authored-By: blink-dev <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
The staleness check failed on its first run, and it was the check that was
wrong, not types.ts. Every difference was in `storage`:

    +          versioning_status: string
    +          archived_at: string | null
    +          is_delete_marker: boolean
    +          is_versioned: boolean

Supabase introspects `storage`, `auth` and `realtime` from whichever
postgres-meta image the CLI pulls — v0.98.0 on that runner — so those schemas
move when the platform ships, not when a migration lands. Regenerating would
not have fixed it, and it would have failed again on the next image bump. A
check that fails for something nobody can act on is one people learn to skip.

`scripts/types-owned-schemas.mjs` slices a generated file down to `public`,
`core`, `community`, `onet` and `logs` — the schemas
packages/supabase/migrations is responsible for — and the workflow compares
those slices instead of the whole file.

Probed in both directions rather than assumed:

  * adding a column to `core.jobs` in a copy → detected
  * adding a column to `storage` in a copy    → ignored

It also generates to /tmp now instead of redirecting over types.ts, so a failed
run no longer leaves a modified working tree behind — the previous version
would have, which is an unpleasant surprise for anyone running it locally.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@thinkclay
thinkclay merged commit f0111b4 into main Sep 15, 2026
14 checks passed
@thinkclay
thinkclay deleted the fix/types-generation-guard branch September 15, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant