feat(db): contracts/05 — add inbound_webhook_events.contract_version column#56
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughMigração que adiciona coluna ChangesMigração: contract_version para inbound_webhook_events
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adds database support for contract versioning used by the migrated webhook-inbound handler (PR #45) by introducing a contract_version column on public.inbound_webhook_events, preventing runtime INSERT failures due to a missing column (closes #49).
Changes:
- Add
contract_version text NOT NULL DEFAULT '1'topublic.inbound_webhook_events(idempotent viaIF NOT EXISTS). - Add a descriptive
COMMENT ON COLUMNforcontract_version. - Add a post-migration sanity check that raises if the column is still missing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| COMMENT ON COLUMN public.inbound_webhook_events.contract_version IS | ||
| 'Versão de contrato negociada via header accept-version. Default 1 (compat com payloads legados).'; | ||
|
|
||
| -- Sanity check: deve existir após o ALTER | ||
| DO $$ | ||
| BEGIN | ||
| IF NOT EXISTS ( | ||
| SELECT 1 FROM information_schema.columns | ||
| WHERE table_schema = 'public' | ||
| AND table_name = 'inbound_webhook_events' | ||
| AND column_name = 'contract_version' | ||
| ) THEN | ||
| RAISE EXCEPTION 'contracts/05 migration: contract_version column was not created'; | ||
| END IF; |
Sumário
Adiciona a coluna
contract_versionà tabelainbound_webhook_events.Por quê
O handler
webhook-inboundmigrado em #45 gravacontract_version: '1'|'2'em todo INSERT. Sem essa coluna no Postgres, o handler vai falhar comcolumn "contract_version" does not existquando #45 for mergeado.O que faz
Risco
Baixo. ALTER TABLE com DEFAULT em coluna nova é metadata-only no PG 12+: não rewrite, não lock pesado, instantâneo mesmo em tabelas grandes. Default '1' garante que linhas pré-migração ganham valor válido automaticamente.
Validação
IF NOT EXISTStorna a migration idempotenteCloses #49
Summary by cubic
Add
contract_versiontoinbound_webhook_eventsto store the negotiated contract version used by thewebhook-inboundhandler. Prevents missing-column errors when #45 lands; closes #49.contract_version(text, NOT NULL, default '1') topublic.inbound_webhook_events.IF NOT EXISTSwith a sanity check that raises if the column is missing.Written for commit 9475684. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
Notas de Lançamento