Saltar al contenido
Skillpedia
APIs y servidores (backend)9,5 mil · #12250

convex-migration-helper

Qué hace

Esta habilidad planifica cambios en la estructura de datos de una app de Convex que ya tiene datos. Está pensada para creadores que necesitan un plan paso a paso que no rompa a los usuarios.

Cuándo usarla

  • ✓Cuando necesitas cambiar el tipo de un campo o dividir una tabla en una app de Convex con datos existentes.
  • ✓Cuando renombras o eliminas campos que todavía usan registros existentes.
  • ✓Cuando quieres un despliegue sin tiempo de inactividad para un cambio de backend.

Link de la skill

https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-migration-helper/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-migration-helper/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Ayúdame a planificar cómo dividir mi tabla de usuarios de Convex en dos tablas sin romper mi app.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente planifica una secuencia de pasos: primero amplía el esquema para que funcionen tanto los datos antiguos como los nuevos, después migra los registros existentes por lotes y, por último, restringe el esquema cuando todo esté actualizado.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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:

  1. Update schema to allow both old and new formats (e.g., add optional new field)
  2. Update code to handle both formats when reading
  3. Update code to write the new format for new documents
  4. Deploy

Between deploys - Migrate data:

  1. Run migration to backfill existing documents
  2. Verify all documents are migrated

Deploy 2 - Narrow the schema:

  1. Update schema to require the new format only
  2. Remove code that handles the old format
  3. 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

  1. Making a field required before migrating data: Convex rejects the deploy because existing documents lack the field. Always widen the schema first.
  2. 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.
  3. Not writing the new format before migrating: Documents created during the migration window will be missed, leaving unmigrated data after the migration "completes."
  4. Skipping the dry run: Use dryRun: true to validate migration logic before committing changes to produ
Preguntas frecuentes

¿Por qué el proceso se hace en pasos?

Convex comprueba los datos existentes frente al esquema, así que los cambios deben hacerse en orden para evitar despliegues fallidos.

¿La app sigue en línea durante el cambio?

Sí. Las migraciones se ejecutan en segundo plano por lotes, pero el código debe gestionar datos antiguos y nuevos durante ese tiempo.

¿Cuándo no hace falta esta habilidad?

En un proyecto nuevo sin datos existentes, o al añadir campos opcionales que no necesitan rellenarse.

Detalles

Descripción original del 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

Popularidad

Estrellas en GitHub
9,5 mil
Posición en el ranking
#12250
Licencia
MIT
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas