convex-migration-helper
Was er macht
Dieser Skill plant Änderungen an der Datenstruktur einer Convex-App, die bereits Daten hat. Er ist für Entwickelnde gedacht, die einen Schritt-für-Schritt-Plan brauchen, der Nutzende nicht beeinträchtigt.
Wann du ihn nutzt
- ✓Wenn du den Feldtyp ändern oder eine Tabelle in einer Convex-App mit bestehenden Daten teilen musst.
- ✓Wenn du Felder umbenennst oder entfernst, die bestehende Datensätze noch verwenden.
- ✓Wenn du eine Backend-Änderung ohne Ausfallzeit ausrollen willst.
Link zum Skill
https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-migration-helper/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Hilf mir zu planen, wie ich meine Convex-Nutzertabelle in zwei Tabellen teile, ohne meine App zu brechen.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Agent plant eine Folge von Schritten: zuerst das Schema so erweitern, dass alte und neue Daten beide funktionieren, dann bestehende Datensätze in Stapeln migrieren und das Schema erst verengen, wenn alles aktualisiert ist.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von 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
Häufige Fragen
Warum wird der Prozess in Schritten ausgeführt?
Convex prüft bestehende Daten gegen das Schema, deshalb müssen Änderungen in der richtigen Reihenfolge erfolgen, damit Deployments nicht fehlschlagen.
Bleibt die App während der Änderung online?
Ja. Migrationen laufen im Hintergrund in Stapeln, der Code muss in dieser Zeit aber alte und neue Daten verarbeiten.
Wann ist dieser Skill nicht nötig?
Bei einem neuen Projekt ohne bestehende Daten oder beim Hinzufügen optionaler Felder, die kein Nachfüllen brauchen.
Details
Originalbeschreibung des Autors
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
Beliebtheit
- GitHub-Sterne
- 9.5k
- Platz im Ranking
- #12250
- Lizenz
- MIT
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
axiom-alerting
9.5kHilft deinem Agenten, Axiom-Monitore und Benachrichtigungswege über die Axiom-API anzulegen und zu verwalten und zu prüfen, ob Warnungen wie erwartet funktionieren.
axiom-sre
9.5kHilft deinem Agenten, Produktionsstörungen und Fehler Schritt für Schritt zu untersuchen und jede Vermutung gegen Axiom-Logs zu prüfen, bevor er ein Ergebnis zieht.
building-dashboards
9.5kHilft deinem Agenten, Axiom-Dashboards mit passenden Diagrammen, Abfragen und Filtern zu entwerfen, ausgehend von den Entscheidungen, die das Dashboard stützen muss.
controlling-costs
9.5kHilft deinem Agenten, ungenutzte Daten in Axiom zu finden und Dashboards und Monitore aufzubauen, die die Logging-Kosten verfolgen und senken.
Ähnliche Skills
api-connector-builder
280kLässt deinen Agenten neue API-Anbindungen nach dem bestehenden Muster bauen. Nutze es, wenn du eine weitere Integration ergänzen willst, ohne neue Wege einzuführen.
api-design
280kHilft deinem Agenten, REST-APIs nach Best Practices zu entwerfen. Nützlich für die Kommunikation, die Fehlerausgabe und die Organisation von Daten.
backend-patterns
280kHilft deinem Agenten bei Architekturmustern für die Serverseite und bei der Datenbankoptimierung. Nützlich zum Bauen und Prüfen von Server-Code.