Skip to content

feat(db): contracts/05 — add inbound_webhook_events.contract_version column#56

Merged
adm01-debug merged 1 commit into
mainfrom
feat/contracts-05-inbound-contract-version-column
May 22, 2026
Merged

feat(db): contracts/05 — add inbound_webhook_events.contract_version column#56
adm01-debug merged 1 commit into
mainfrom
feat/contracts-05-inbound-contract-version-column

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 22, 2026

Sumário

Adiciona a coluna contract_version à tabela inbound_webhook_events.

Por quê

O handler webhook-inbound migrado em #45 grava contract_version: '1'|'2' em todo INSERT. Sem essa coluna no Postgres, o handler vai falhar com column "contract_version" does not exist quando #45 for mergeado.

O que faz

ALTER TABLE public.inbound_webhook_events
  ADD COLUMN IF NOT EXISTS contract_version text NOT NULL DEFAULT '1';
  • comentário descritivo na coluna + sanity check no fim da migration (raise exception se a coluna não existir após o ALTER, evita silent partial-apply).

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

Closes #49


Summary by cubic

Add contract_version to inbound_webhook_events to store the negotiated contract version used by the webhook-inbound handler. Prevents missing-column errors when #45 lands; closes #49.

  • Migration
    • Adds contract_version (text, NOT NULL, default '1') to public.inbound_webhook_events.
    • Idempotent via IF NOT EXISTS with a sanity check that raises if the column is missing.
    • Metadata-only on Postgres 12+, avoiding table rewrite and heavy locks.

Written for commit 9475684. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

Notas de Lançamento

  • Novas Funcionalidades
    • Adicionado suporte completo a versionamento de contrato para webhooks de entrada. Permite melhor compatibilidade com diferentes versões da API de forma totalmente transparente. Nenhuma alteração é necessária nas integrações existentes. Compatibilidade total com payloads antigos é mantida automaticamente, garantindo uma transição suave e absolutamente sem impacto em ambientes de produção.

Review Change Stack

… '1')

Required by webhook-inbound handler migrated in #45. Stores the contract
version negotiated via accept-version header. Default '1' for compat
with all existing rows and unversioned clients.

Closes #49
Copilot AI review requested due to automatic review settings May 22, 2026 00:36
@supabase
Copy link
Copy Markdown

supabase Bot commented May 22, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln due to reaching the limit of concurrent preview branches.
Go to Project Integrations Settings ↗︎ if you wish to update this limit.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
we-dream-big Ready Ready Preview, Comment May 22, 2026 12:36am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3aaf0bdb-93db-4533-bcc6-6cae2b8edf2b

📥 Commits

Reviewing files that changed from the base of the PR and between 4383445 and 9475684.

📒 Files selected for processing (1)
  • supabase/migrations/20260522001000_add_contract_version_to_inbound_webhook_events.sql

Walkthrough

Migração que adiciona coluna contract_version à tabela public.inbound_webhook_events, permitindo rastrear a versão de contrato negociada via header accept-version. O DEFAULT '1' preserva compatibilidade com eventos legados. Inclui sanity check para confirmar criação dentro de transação.

Changes

Migração: contract_version para inbound_webhook_events

Layer / File(s) Summary
Migração e validação de contract_version
supabase/migrations/20260522001000_add_contract_version_to_inbound_webhook_events.sql
Adiciona coluna contract_version (text, NOT NULL, DEFAULT '1') com comentário descritivo e bloco DO $$ para sanity check pós-ALTER dentro de transação explícita.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed O título descreve com precisão a alteração principal: adicionar a coluna contract_version à tabela inbound_webhook_events.
Linked Issues check ✅ Passed A migração atende todos os critérios técnicos: cria a coluna com tipo text, DEFAULT '1', adiciona COMMENT descritivo, e inclui sanity check para garantir a aplicação.
Out of Scope Changes check ✅ Passed Nenhuma alteração fora do escopo. A migração está focada exclusivamente em adicionar a coluna contract_version conforme especificado na issue #49.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/contracts-05-inbound-contract-version-column

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' to public.inbound_webhook_events (idempotent via IF NOT EXISTS).
  • Add a descriptive COMMENT ON COLUMN for contract_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 lines +15 to +28
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;
@adm01-debug adm01-debug merged commit 385522e into main May 22, 2026
28 of 32 checks passed
@adm01-debug adm01-debug deleted the feat/contracts-05-inbound-contract-version-column branch May 24, 2026 18:55
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.

contracts/05 — Adicionar coluna inbound_webhook_events.contract_version

2 participants