# Send database-migrations to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "database-migrations",
    "name": "database-migrations",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/wpank/database-migrations",
    "canonicalUrl": "https://clawhub.ai/wpank/database-migrations",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/database-migrations",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=database-migrations",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "README.md",
      "SKILL.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "database-migrations",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-11T22:16:02.052Z",
      "expiresAt": "2026-05-18T22:16:02.052Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=database-migrations",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=database-migrations",
        "contentDisposition": "attachment; filename=\"database-migrations-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "database-migrations"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/database-migrations"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/database-migrations",
    "downloadUrl": "https://openagent3.xyz/downloads/database-migrations",
    "agentUrl": "https://openagent3.xyz/skills/database-migrations/agent",
    "manifestUrl": "https://openagent3.xyz/skills/database-migrations/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/database-migrations/agent.md"
  }
}
```
## Documentation

### Schema Evolution Strategies

StrategyRiskDowntimeBest ForAdditive-OnlyVery LowNoneAPIs with backward-compatibility guaranteesExpand-ContractLowNoneRenaming, restructuring, type changesParallel ChangeLowNoneHigh-risk changes on critical tablesLazy MigrationMediumNoneLarge tables where bulk migration is too slowBig BangHighYesDev/staging or small datasets only

Default to Additive-Only. Escalate to Expand-Contract only when you must modify or remove existing structures.

### Zero-Downtime Patterns

Every production migration must avoid locking tables or breaking running application code.

OperationPatternKey ConstraintAdd columnNullable firstNever add NOT NULL without default on large tablesRename columnExpand-contractAdd new → dual-write → backfill → switch reads → drop oldDrop columnDeprecate firstStop reading → stop writing → deploy → dropChange typeParallel columnAdd new type → dual-write + cast → switch → drop oldAdd indexConcurrentCREATE INDEX CONCURRENTLY — don't wrap in transactionSplit tableExtract + FKCreate new → backfill → add FK → update queries → drop old columnsChange constraintTwo-phaseAdd NOT VALID → VALIDATE CONSTRAINT separatelyAdd enum valueAppend onlyNever remove or rename existing values

### Migration Tools

ToolEcosystemStyleKey StrengthPrisma MigrateTypeScript/NodeDeclarative (schema diff)ORM integration, shadow DBKnexJavaScript/NodeImperative (up/down)Lightweight, flexibleDrizzle KitTypeScript/NodeDeclarative (schema diff)Type-safe, SQL-likeAlembicPythonImperative (upgrade/downgrade)Granular control, autogenerateDjango MigrationsPython/DjangoDeclarative (model diff)Auto-detectionFlywayJVM / CLISQL file versioningSimple, wide DB supportgolang-migrateGo / CLISQL (up/down files)Minimal, embeddableAtlasGo / CLIDeclarative (HCL/SQL diff)Schema-as-code, linting, CI

Match the tool to your ORM and deployment pipeline. Prefer declarative for simple schemas, imperative for fine-grained data manipulation.

### Rollback Strategies

ApproachWhen to UseReversible (up + down)Schema-only changes, early-stage productsForward-only (corrective migration)Data-destructive changes, production at scaleHybridReversible for schema, forward-only for data

### Data Preservation

Soft-delete columns — rename with _deprecated suffix instead of dropping
Snapshot tables — CREATE TABLE _backup_<table>_<date> AS SELECT * FROM <table>
Point-in-time recovery — ensure WAL archiving covers migration windows
Logical backups — pg_dump of affected tables before migration

### Blue-Green Database

1. Replicate primary → secondary (green)
2. Apply migration to green
3. Run validation suite against green
4. Switch traffic to green
5. Keep blue as rollback target (N hours)
6. Decommission blue after confidence window

### Backfill Strategies

StrategyBest ForInline backfillSmall tables (< 100K rows)Batched backfillMedium tables (100K–10M rows)Background jobLarge tables (10M+ rows)Lazy backfillWhen immediate consistency not required

### Batch Processing

DO $$
DECLARE
  batch_size INT := 1000;
  rows_updated INT;
BEGIN
  LOOP
    UPDATE my_table
    SET new_col = compute_value(old_col)
    WHERE id IN (
      SELECT id FROM my_table
      WHERE new_col IS NULL
      LIMIT batch_size
      FOR UPDATE SKIP LOCKED
    );
    GET DIAGNOSTICS rows_updated = ROW_COUNT;
    EXIT WHEN rows_updated = 0;
    PERFORM pg_sleep(0.1);  -- throttle to reduce lock pressure
    COMMIT;
  END LOOP;
END $$;

### Dual-Write Period

For expand-contract and parallel change:

Dual-write — application writes to both old and new columns/tables
Backfill — fill new structure with historical data
Verify — assert consistency (row counts, checksums)
Cut over — switch reads to new, stop writing to old
Cleanup — drop old structure after cool-down period

### Test Against Production-Like Data

Never test against empty or synthetic data only
Use anonymized production snapshots
Match data volume — a migration working on 1K rows may lock on 10M
Reproduce edge cases: NULLs, empty strings, max-length, unicode

### Migration CI Pipeline

- name: Test migrations
  steps:
    - run: docker compose up -d db
    - run: npm run migrate:up        # apply all
    - run: npm run migrate:down      # rollback all
    - run: npm run migrate:up        # re-apply (idempotency)
    - run: npm run test:integration  # validate app
    - run: npm run migrate:status    # no pending

Every migration PR must pass: up → down → up → tests.

### Pre-Migration

Tested against production-like data volume
 Rollback written and tested
 Backup of affected tables created
 App code compatible with both old and new schema
 Execution time benchmarked on staging
 Lock impact analyzed
 Replication lag monitoring in place

### During Migration

Monitor lock waits and active queries
 Monitor replication lag
 Watch for error rate spikes
 Keep rollback command ready

### Post-Migration

Schema matches expected state
 Integration tests pass against migrated DB
 Data integrity validated (row counts, checksums)
 ORM schema / type definitions updated
 Deprecated structures cleaned up after cool-down
 Migration documented in team runbook

### NEVER Do

NEVER run untested migrations directly in production
NEVER drop a column without first removing all application references and deploying
NEVER add NOT NULL to a large table without a default value in a single statement
NEVER mix schema DDL and data mutations in the same migration file
NEVER skip the dual-write phase when renaming columns in a live system
NEVER assume migrations are instantaneous — always benchmark on production-scale data
NEVER disable foreign key checks to "speed up" migrations in production
NEVER deploy application code that depends on a schema change before the migration has completed
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: wpank
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-11T22:16:02.052Z
- Expires at: 2026-05-18T22:16:02.052Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/database-migrations)
- [Send to Agent page](https://openagent3.xyz/skills/database-migrations/agent)
- [JSON manifest](https://openagent3.xyz/skills/database-migrations/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/database-migrations/agent.md)
- [Download page](https://openagent3.xyz/downloads/database-migrations)