{
  "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": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/database-migrations",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=database-migrations",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "README.md",
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "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."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "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."
        },
        {
          "label": "Upgrade existing",
          "body": "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."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T17:22:31.273Z",
      "expiresAt": "2026-05-14T17:22:31.273Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
        "contentDisposition": "attachment; filename=\"afrexai-annual-report-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "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."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/database-migrations",
    "agentPageUrl": "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"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "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."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "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."
      },
      {
        "label": "Upgrade existing",
        "body": "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."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Schema Evolution Strategies",
        "body": "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\n\nDefault to Additive-Only. Escalate to Expand-Contract only when you must modify or remove existing structures."
      },
      {
        "title": "Zero-Downtime Patterns",
        "body": "Every production migration must avoid locking tables or breaking running application code.\n\nOperationPatternKey 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"
      },
      {
        "title": "Migration Tools",
        "body": "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\n\nMatch the tool to your ORM and deployment pipeline. Prefer declarative for simple schemas, imperative for fine-grained data manipulation."
      },
      {
        "title": "Rollback Strategies",
        "body": "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"
      },
      {
        "title": "Data Preservation",
        "body": "Soft-delete columns — rename with _deprecated suffix instead of dropping\nSnapshot tables — CREATE TABLE _backup_<table>_<date> AS SELECT * FROM <table>\nPoint-in-time recovery — ensure WAL archiving covers migration windows\nLogical backups — pg_dump of affected tables before migration"
      },
      {
        "title": "Blue-Green Database",
        "body": "1. Replicate primary → secondary (green)\n2. Apply migration to green\n3. Run validation suite against green\n4. Switch traffic to green\n5. Keep blue as rollback target (N hours)\n6. Decommission blue after confidence window"
      },
      {
        "title": "Backfill Strategies",
        "body": "StrategyBest ForInline backfillSmall tables (< 100K rows)Batched backfillMedium tables (100K–10M rows)Background jobLarge tables (10M+ rows)Lazy backfillWhen immediate consistency not required"
      },
      {
        "title": "Batch Processing",
        "body": "DO $$\nDECLARE\n  batch_size INT := 1000;\n  rows_updated INT;\nBEGIN\n  LOOP\n    UPDATE my_table\n    SET new_col = compute_value(old_col)\n    WHERE id IN (\n      SELECT id FROM my_table\n      WHERE new_col IS NULL\n      LIMIT batch_size\n      FOR UPDATE SKIP LOCKED\n    );\n    GET DIAGNOSTICS rows_updated = ROW_COUNT;\n    EXIT WHEN rows_updated = 0;\n    PERFORM pg_sleep(0.1);  -- throttle to reduce lock pressure\n    COMMIT;\n  END LOOP;\nEND $$;"
      },
      {
        "title": "Dual-Write Period",
        "body": "For expand-contract and parallel change:\n\nDual-write — application writes to both old and new columns/tables\nBackfill — fill new structure with historical data\nVerify — assert consistency (row counts, checksums)\nCut over — switch reads to new, stop writing to old\nCleanup — drop old structure after cool-down period"
      },
      {
        "title": "Test Against Production-Like Data",
        "body": "Never test against empty or synthetic data only\nUse anonymized production snapshots\nMatch data volume — a migration working on 1K rows may lock on 10M\nReproduce edge cases: NULLs, empty strings, max-length, unicode"
      },
      {
        "title": "Migration CI Pipeline",
        "body": "- name: Test migrations\n  steps:\n    - run: docker compose up -d db\n    - run: npm run migrate:up        # apply all\n    - run: npm run migrate:down      # rollback all\n    - run: npm run migrate:up        # re-apply (idempotency)\n    - run: npm run test:integration  # validate app\n    - run: npm run migrate:status    # no pending\n\nEvery migration PR must pass: up → down → up → tests."
      },
      {
        "title": "Pre-Migration",
        "body": "Tested against production-like data volume\n Rollback written and tested\n Backup of affected tables created\n App code compatible with both old and new schema\n Execution time benchmarked on staging\n Lock impact analyzed\n Replication lag monitoring in place"
      },
      {
        "title": "During Migration",
        "body": "Monitor lock waits and active queries\n Monitor replication lag\n Watch for error rate spikes\n Keep rollback command ready"
      },
      {
        "title": "Post-Migration",
        "body": "Schema matches expected state\n Integration tests pass against migrated DB\n Data integrity validated (row counts, checksums)\n ORM schema / type definitions updated\n Deprecated structures cleaned up after cool-down\n Migration documented in team runbook"
      },
      {
        "title": "NEVER Do",
        "body": "NEVER run untested migrations directly in production\nNEVER drop a column without first removing all application references and deploying\nNEVER add NOT NULL to a large table without a default value in a single statement\nNEVER mix schema DDL and data mutations in the same migration file\nNEVER skip the dual-write phase when renaming columns in a live system\nNEVER assume migrations are instantaneous — always benchmark on production-scale data\nNEVER disable foreign key checks to \"speed up\" migrations in production\nNEVER deploy application code that depends on a schema change before the migration has completed"
      }
    ],
    "body": "Database Migration Patterns\nSchema Evolution Strategies\nStrategy\tRisk\tDowntime\tBest For\nAdditive-Only\tVery Low\tNone\tAPIs with backward-compatibility guarantees\nExpand-Contract\tLow\tNone\tRenaming, restructuring, type changes\nParallel Change\tLow\tNone\tHigh-risk changes on critical tables\nLazy Migration\tMedium\tNone\tLarge tables where bulk migration is too slow\nBig Bang\tHigh\tYes\tDev/staging or small datasets only\n\nDefault to Additive-Only. Escalate to Expand-Contract only when you must modify or remove existing structures.\n\nZero-Downtime Patterns\n\nEvery production migration must avoid locking tables or breaking running application code.\n\nOperation\tPattern\tKey Constraint\nAdd column\tNullable first\tNever add NOT NULL without default on large tables\nRename column\tExpand-contract\tAdd new → dual-write → backfill → switch reads → drop old\nDrop column\tDeprecate first\tStop reading → stop writing → deploy → drop\nChange type\tParallel column\tAdd new type → dual-write + cast → switch → drop old\nAdd index\tConcurrent\tCREATE INDEX CONCURRENTLY — don't wrap in transaction\nSplit table\tExtract + FK\tCreate new → backfill → add FK → update queries → drop old columns\nChange constraint\tTwo-phase\tAdd NOT VALID → VALIDATE CONSTRAINT separately\nAdd enum value\tAppend only\tNever remove or rename existing values\nMigration Tools\nTool\tEcosystem\tStyle\tKey Strength\nPrisma Migrate\tTypeScript/Node\tDeclarative (schema diff)\tORM integration, shadow DB\nKnex\tJavaScript/Node\tImperative (up/down)\tLightweight, flexible\nDrizzle Kit\tTypeScript/Node\tDeclarative (schema diff)\tType-safe, SQL-like\nAlembic\tPython\tImperative (upgrade/downgrade)\tGranular control, autogenerate\nDjango Migrations\tPython/Django\tDeclarative (model diff)\tAuto-detection\nFlyway\tJVM / CLI\tSQL file versioning\tSimple, wide DB support\ngolang-migrate\tGo / CLI\tSQL (up/down files)\tMinimal, embeddable\nAtlas\tGo / CLI\tDeclarative (HCL/SQL diff)\tSchema-as-code, linting, CI\n\nMatch the tool to your ORM and deployment pipeline. Prefer declarative for simple schemas, imperative for fine-grained data manipulation.\n\nRollback Strategies\nApproach\tWhen to Use\nReversible (up + down)\tSchema-only changes, early-stage products\nForward-only (corrective migration)\tData-destructive changes, production at scale\nHybrid\tReversible for schema, forward-only for data\nData Preservation\nSoft-delete columns — rename with _deprecated suffix instead of dropping\nSnapshot tables — CREATE TABLE _backup_<table>_<date> AS SELECT * FROM <table>\nPoint-in-time recovery — ensure WAL archiving covers migration windows\nLogical backups — pg_dump of affected tables before migration\nBlue-Green Database\n1. Replicate primary → secondary (green)\n2. Apply migration to green\n3. Run validation suite against green\n4. Switch traffic to green\n5. Keep blue as rollback target (N hours)\n6. Decommission blue after confidence window\n\nData Migration Patterns\nBackfill Strategies\nStrategy\tBest For\nInline backfill\tSmall tables (< 100K rows)\nBatched backfill\tMedium tables (100K–10M rows)\nBackground job\tLarge tables (10M+ rows)\nLazy backfill\tWhen immediate consistency not required\nBatch Processing\nDO $$\nDECLARE\n  batch_size INT := 1000;\n  rows_updated INT;\nBEGIN\n  LOOP\n    UPDATE my_table\n    SET new_col = compute_value(old_col)\n    WHERE id IN (\n      SELECT id FROM my_table\n      WHERE new_col IS NULL\n      LIMIT batch_size\n      FOR UPDATE SKIP LOCKED\n    );\n    GET DIAGNOSTICS rows_updated = ROW_COUNT;\n    EXIT WHEN rows_updated = 0;\n    PERFORM pg_sleep(0.1);  -- throttle to reduce lock pressure\n    COMMIT;\n  END LOOP;\nEND $$;\n\nDual-Write Period\n\nFor expand-contract and parallel change:\n\nDual-write — application writes to both old and new columns/tables\nBackfill — fill new structure with historical data\nVerify — assert consistency (row counts, checksums)\nCut over — switch reads to new, stop writing to old\nCleanup — drop old structure after cool-down period\nTesting Migrations\nTest Against Production-Like Data\nNever test against empty or synthetic data only\nUse anonymized production snapshots\nMatch data volume — a migration working on 1K rows may lock on 10M\nReproduce edge cases: NULLs, empty strings, max-length, unicode\nMigration CI Pipeline\n- name: Test migrations\n  steps:\n    - run: docker compose up -d db\n    - run: npm run migrate:up        # apply all\n    - run: npm run migrate:down      # rollback all\n    - run: npm run migrate:up        # re-apply (idempotency)\n    - run: npm run test:integration  # validate app\n    - run: npm run migrate:status    # no pending\n\n\nEvery migration PR must pass: up → down → up → tests.\n\nMigration Checklist\nPre-Migration\n Tested against production-like data volume\n Rollback written and tested\n Backup of affected tables created\n App code compatible with both old and new schema\n Execution time benchmarked on staging\n Lock impact analyzed\n Replication lag monitoring in place\nDuring Migration\n Monitor lock waits and active queries\n Monitor replication lag\n Watch for error rate spikes\n Keep rollback command ready\nPost-Migration\n Schema matches expected state\n Integration tests pass against migrated DB\n Data integrity validated (row counts, checksums)\n ORM schema / type definitions updated\n Deprecated structures cleaned up after cool-down\n Migration documented in team runbook\nNEVER Do\nNEVER run untested migrations directly in production\nNEVER drop a column without first removing all application references and deploying\nNEVER add NOT NULL to a large table without a default value in a single statement\nNEVER mix schema DDL and data mutations in the same migration file\nNEVER skip the dual-write phase when renaming columns in a live system\nNEVER assume migrations are instantaneous — always benchmark on production-scale data\nNEVER disable foreign key checks to \"speed up\" migrations in production\nNEVER deploy application code that depends on a schema change before the migration has completed"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/wpank/database-migrations",
    "publisherUrl": "https://clawhub.ai/wpank/database-migrations",
    "owner": "wpank",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "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"
  }
}