cloudflare-d1-migrations-and-production-seeding

Manage Cloudflare D1 schema migrations and environment-specific data seeding.

2|Updated Dec 5, 2025
One-click install
npx skills add https://github.com/AgentiveCity/SkillFactory --skill cloudflare-d1-migrations-and-production-seeding
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloudflare-d1-migrations-and-production-seeding
Source: https://github.com/AgentiveCity/SkillFactory/tree/main/.claude/skills/cloudflare-d1-migrations-and-production-seeding
Command: npx skills add https://github.com/AgentiveCity/SkillFactory --skill cloudflare-d1-migrations-and-production-seeding

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solves?

Designing, running, or refining Cloudflare D1 schema management, migrations, and data seeding for dev/staging/production environments can be complex and error-prone, especially with Hono/Workers apps. This Skill automates the lifecycle, ensuring predictable, reproducible, and safe D1 schema evolution across all environments.

Core Features & Use Cases

  • Automated Schema & Migration Management: Design D1 schemas using SQL and manage migrations via Wrangler, ensuring append-only changes and version control.
  • Environment-Aware Migration Workflows: Implement safe migration strategies for dev, staging, and production databases, including package.json scripts for repeatable execution.
  • Data Seeding & Evolution: Create seed scripts for development/test data and plan for safe data migrations (e.g., column renames) without losing data.

Quick Start

Create initial D1 schema and migrations for users/posts, set up dev/staging/prod migration commands for D1, and add seeding for local dev.

Frequently Asked Questions about cloudflare-d1-migrations-and-production-seeding

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up D1 database migrations for Cloudflare Workers?

D1 migrations manage schema evolution through versioned SQL files executed via Wrangler. Create migration files in your project, define SQL changes (CREATE TABLE, ALTER, etc.), and run them sequentially across dev, staging, and production environments using `wrangler d1 migrations apply`. This ensures schema consistency and reproducibility across all environments.

Can I safely evolve my D1 schema without losing data?

Yes. D1 migrations support safe, append-only schema changes—adding columns, creating tables, or renaming columns without data loss. Plan destructive changes carefully, use data migration scripts within migration files, and test in dev/staging before production. Versioned migrations create an audit trail of all schema changes.

How do I seed different data across dev, staging, and production D1 databases?

Create environment-specific seed scripts and reference them via `package.json` scripts or Wrangler bindings. Execute seeds after migrations to populate initial or test data. D1 supports conditional seeding—run development fixtures locally, minimal seeds in staging, and production data loads separately, ensuring isolation and repeatability.

What's the best way to automate D1 migrations in a CI/CD pipeline?

Integrate Wrangler migration commands into CI/CD workflows using `wrangler d1 migrations apply` with environment-specific bindings. Version control migration files, run migrations before deploying Workers code, and use idempotent migration patterns to handle retries safely. This ensures schema and code deploy together reliably.

Does Cloudflare D1 support idempotent migrations?

D1 tracks executed migrations by version to prevent re-execution. Design migrations as idempotent—use `IF NOT EXISTS` for schema creation and conditional logic for data changes—so reruns don't fail. This pattern enables safe retry logic and robust CI/CD integration.

Can I use D1 migrations with Hono or other Workers frameworks?

Yes. D1 migrations work alongside any Workers framework via Wrangler bindings and D1 database connections. Define migrations independently, execute them during deployment or via scheduled tasks, then query D1 from your Hono or Workers code. Migrations and application code remain decoupled.