# DB Migrations

> D1 database migration patterns for WordPress MCP Use when this capability is needed.

- Skill: `tomevault-io/db-migrations` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/db-migrations`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/db-migrations/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/db-migrations

---


# D1 Migrations Reference

## Commands

```bash
# Run locally
npx wrangler d1 execute wordpress-mcp-db --local --file=./migrations/001_initial.sql

# Run on production
npx wrangler d1 execute wordpress-mcp-db --remote --file=./migrations/001_initial.sql

# Query
npx wrangler d1 execute wordpress-mcp-db --remote --command "SELECT * FROM users LIMIT 5"
```

## WordPress Connection Schema

```sql
CREATE TABLE wordpress_connections (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  name TEXT NOT NULL,
  wordpress_url TEXT NOT NULL,
  username TEXT NOT NULL,
  app_password_encrypted TEXT NOT NULL,  -- AES-256-GCM encrypted
  created_at TEXT DEFAULT (datetime('now'))
);
CREATE INDEX idx_wp_conn_user ON wordpress_connections(user_id);
```

## Important Notes

1. **Application Password must be encrypted** — Never store plaintext
2. **Spaces must be removed** before encryption
3. **Use ON DELETE CASCADE** for child tables

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/kaewz-manga) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

