Repository navigation
ci(deploy): gate on the real schema, not on a DB secret - #90
Merged
Merged
Conversation
Merging to main deploys to production with no schema gate: the CRM hardening PR shipped code writing six columns the database did not have, and every lead write answered PGRST204 until the migrations were applied by hand. The deploy workflow now compares database.types.ts — the contract the whole codebase is typed against — with the PostgREST root spec of the target project, and fails before building when a table or column the app needs is absent. It reuses the service role key the deploy already has, so it needs no new secret and no database password. Parsing and diffing are pure and unit tested; the runner also accepts --spec for an offline check.
juancodedev
force-pushed
the
chore/deploy-migration-gate
branch
from
November 13, 2026 01:26
3118abd to
59a39e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reemplaza el gate del #89, que quedó en
mainy rompió el deploy (de1f1f7) porque exigía el secretSUPABASE_DB_URL, que no existe.En vez de comparar el historial de migraciones contra la base, compara el contrato de la app contra el esquema que producción sirve de verdad. Reutiliza
NEXT_PUBLIC_SUPABASE_URLySUPABASE_SERVICE_ROLE_KEY, que el deploy ya tiene: cero secrets nuevos, cero passwords.src/infrastructure/database/database.types.tses el contrato contra el que está tipada toda la app. Si producción no tiene una tabla o columna declarada ahí, el deploy falla antes de buildear y lista exactamente qué falta:Ese output es el del esquema de la semana pasada, reproducido offline con
--spec: el gate habría frenado el PR #87.Cambios
src/lib/deploy/schema-drift.tssrc/lib/deploy/__tests__/schema-drift.spec.tsdatabase.types.tsrealscripts/check-schema-drift.mjs--specpara verificar sin red.github/workflows/deploy.ymlREADME.mdscripts/check-pending-migrations.shVerificación
jest— 112 suites / 825 teststsc --noEmitlimpioeslint . --max-warnings 30— 0 errores, 12 warnings preexistentesde1f1f7eliminadoRisk: item 5 (CI/deploy).