본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)9.5k · #12250

convex-migration-helper

하는 일

이 스킬은 이미 데이터가 있는 Convex 앱의 데이터 구조 변경을 계획합니다. 사용자를 깨뜨리지 않는 단계별 계획이 필요한 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓기존 데이터가 있는 Convex 앱에서 필드 타입을 바꾸거나 테이블을 나눠야 할 때.
  • ✓기존 레코드가 여전히 쓰는 필드의 이름을 바꾸거나 제거할 때.
  • ✓백엔드 변경에 대해 무중단 배포를 원하는 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-migration-helper/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“앱을 깨뜨리지 않고 제 Convex users 테이블을 두 테이블로 나누는 방법을 계획해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 단계 순서를 계획합니다. 먼저 스키마를 넓혀 기존 데이터와 새 데이터가 모두 작동하게 하고, 그다음 기존 레코드를 배치로 마이그레이션한 뒤, 모든 것이 업데이트되면 스키마를 좁힙니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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
자주 묻는 질문

왜 단계별로 진행하나요?

Convex가 기존 데이터를 스키마와 대조하므로, 배포 실패를 피하려면 변경이 순서대로 일어나야 하기 때문입니다.

변경 중에도 앱이 온라인인가요?

예. 마이그레이션은 배치 단위로 백그라운드에서 실행되지만, 코드는 변경 중 옛 데이터와 새 데이터를 모두 처리해야 합니다.

이 스킬이 필요 없는 경우는 언제인가요?

기존 데이터가 없는 새 프로젝트나, 백필이 필요 없는 선택 필드를 추가할 때입니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
9.5k
순위
#12250
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬