Agent skill

db-migrate

Run D1 database migrations for Cloudflare. Use when applying schema changes, creating new tables, or modifying database structure.

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/db-migrate-pentatonic-ltd-claude-config

SKILL.md

D1 Database Migrations

Project Database

  • Database name: agentic-commerce-p2p-db
  • Location: migrations/ directory

List Existing Migrations

bash
ls -la migrations/

Apply Migrations (Remote)

bash
npx wrangler d1 execute agentic-commerce-p2p-db --remote --file=migrations/YOUR_MIGRATION.sql

Apply All Pending Migrations

bash
npx wrangler d1 migrations apply agentic-commerce-p2p-db --remote

Check Current Schema

bash
npx wrangler d1 execute agentic-commerce-p2p-db --remote --command="SELECT name FROM sqlite_master WHERE type='table';"

Creating New Migrations

  1. Create file: migrations/NNN_description.sql
  2. Use sequential numbering (e.g., 019, 020)
  3. Include both up and down if possible
  4. Test locally first with --local flag

Local Testing

bash
npx wrangler d1 execute agentic-commerce-p2p-db --local --file=migrations/YOUR_MIGRATION.sql

Rollback

D1 doesn't have built-in rollback. Create a reverse migration manually.

Best Practices

  • Always backup before major schema changes
  • Test migrations locally first
  • Use transactions where possible
  • Document breaking changes

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results