convex-migration-helper
O que ela faz
Esta skill planeja mudanças na estrutura de dados de um app Convex que já tem dados. É para quem precisa de um plano passo a passo que não quebre os usuários.
Quando usar
- ✓Quando você precisa mudar o tipo de um campo ou dividir uma tabela em um app Convex com dados existentes.
- ✓Quando está renomeando ou removendo campos que registros existentes ainda usam.
- ✓Quando quer uma implantação de mudança de backend sem tempo de parada.
Link da skill
https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-migration-helper/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Me ajude a planejar como dividir minha tabela de usuários da Convex em duas tabelas sem quebrar meu app.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente planeja uma sequência de etapas: primeiro amplia o schema para que dados antigos e novos funcionem, depois migra os registros existentes em lotes e por fim restringe o schema quando tudo estiver atualizado.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do GitHub.
Convex Migration Helper
Safely migrate Convex schemas and data when making breaking changes.
When to Use
- Adding new required fields to existing tables
- Changing field types or structure
- Splitting or merging tables
- Renaming or deleting fields
- Migrating from nested to relational data
When Not to Use
- Greenfield schema with no existing data in production or dev
- Adding optional fields that do not need backfilling
- Adding new tables with no existing data to migrate
- Adding or removing indexes with no correctness concern
- Questions about Convex schema design without a migration need
Key Concepts
Schema Validation Drives the Workflow
Convex will not let you deploy a schema that does not match the data at rest. This is the fundamental constraint that shapes every migration:
- You cannot add a required field if existing documents don't have it
- You cannot change a field's type if existing documents have the old type
- You cannot remove a field from the schema if existing documents still have it
This means migrations follow a predictable pattern: widen the schema, migrate the data, narrow the schema.
Online Migrations
Convex migrations run online, meaning the app continues serving requests while data is updated asynchronously in batches. During the migration window, your code must handle both old and new data formats.
Prefer New Fields Over Changing Types
When changing the shape of data, create a new field rather than modifying an existing one. This makes the transition safer and easier to roll back.
Don't Delete Data
Unless you are certain, prefer deprecating fields over deleting them. Mark the
field as v.optional and add a code comment explaining it is deprecated and why
it existed.
Safe Changes (No Migration Needed)
Adding Optional Field
// Before
users: defineTable({
name: v.string(),
});
// After - safe, new field is optional
users: defineTable({
name: v.string(),
bio: v.optional(v.string()),
});
Adding New Table
posts: defineTable({
userId: v.id("users"),
title: v.string(),
}).index("by_user", ["userId"]);
Adding Index
users: defineTable({
name: v.string(),
email: v.string(),
}).index("by_email", ["email"]);
Breaking Changes: The Deployment Workflow
Every breaking migration follows the same multi-deploy pattern:
Deploy 1 - Widen the schema:
- Update schema to allow both old and new formats (e.g., add optional new field)
- Update code to handle both formats when reading
- Update code to write the new format for new documents
- Deploy
Between deploys - Migrate data:
- Run migration to backfill existing documents
- Verify all documents are migrated
Deploy 2 - Narrow the schema:
- Update schema to require the new format only
- Remove code that handles the old format
- Deploy
Using the Migrations Component
For any non-trivial migration, use the
@convex-dev/migrations
component. It handles batching, cursor-based pagination, state tracking, resume
from failure, dry runs, and progress monitoring.
See references/migrations-component.md for installation, setup, defining and
running migrations directly with npx convex run migrations:myMigration, dry
runs, status monitoring, and configuration options.
Common Migration Patterns
See references/migration-patterns.md for complete patterns with code examples
covering:
- Adding a required field
- Deleting a field
- Changing a field type
- Splitting nested data into a separate table
- Cleaning up orphaned documents
- Zero-downtime strategies (dual write, dual read)
- Small table shortcut (single internalMutation without the component)
- Verifying a migration is complete
Common Pitfalls
- Making a field required before migrating data: Convex rejects the deploy because existing documents lack the field. Always widen the schema first.
- Using
.collect()on large tables: Hits transaction limits or causes timeouts. Use the migrations component for proper batched pagination..collect()is only safe for tables you know are small. - Not writing the new format before migrating: Documents created during the migration window will be missed, leaving unmigrated data after the migration "completes."
- Skipping the dry run: Use
dryRun: trueto validate migration logic before committing changes to produ
Perguntas frequentes
Por que o processo é feito em etapas?
A Convex confere os dados existentes com o schema, então as mudanças precisam acontecer na ordem certa para evitar falhas nas publicações.
O app continua no ar durante a mudança?
Sim. As migrações rodam em segundo plano, em lotes, mas o código precisa lidar com dados antigos e novos durante esse tempo.
Quando essa skill não é necessária?
Em um projeto novo, sem dados existentes, ou para adicionar campos opcionais que não precisam de preenchimento.
Detalhes
Descrição original do autor
Plans Convex schema and data migrations with widen-migrate-narrow and @convex-dev/migrations. Use for breaking schema changes, backfills, table reshaping, or zero-downtime rollouts.
repo: openclaw/clawhub
Popularidade
- Estrelas no GitHub
- 9,5 mil
- Posição no ranking
- #12250
- Licença
- MIT
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
axiom-alerting
9,5 milAjuda seu agente a criar e gerenciar monitores e rotas de notificação do Axiom pela API do Axiom, e a verificar se os alertas se comportam como esperado.
axiom-sre
9,5 milAjuda seu agente a investigar incidentes e bugs de produção passo a passo, testando cada hipótese contra os logs do Axiom antes de tirar uma conclusão.
building-dashboards
9,5 milAjuda seu agente a desenhar dashboards do Axiom com gráficos, consultas e filtros adequados, partindo das decisões que o dashboard precisa apoiar.
controlling-costs
9,5 milAjuda seu agente a encontrar dados não usados no Axiom e a criar dashboards e monitores que acompanham e reduzem os custos de logs.
Skills parecidas
api-connector-builder
280 milFaz seu agente construir novas conexões com APIs seguindo o padrão já existente. Use quando precisar adicionar mais uma integração sem criar um novo jeito de fazer.
api-design
280 milAjuda seu agente a projetar APIs REST seguindo as melhores práticas. É útil para definir como as APIs se comunicam, como os erros são mostrados e como organizar os dados.
backend-patterns
280 milAjuda seu agente com padrões de arquitetura do lado do servidor e otimização de banco de dados. É útil para construir ou revisar o código que roda no servidor.