devlab-db-data-migration

devlab-db-data-migration is a skill for Claude Code, Codex from seed-forge/harness-ai-kit. It costs 165 tokens per session (1,327 once invoked), scanned A, original, Apache-2.0.

A guide to safely changing existing database tables and moving their data. It covers backups, repeatable checks, migration, verification, and restoring the backup if something fails.

In plain words
What is it for?
Use it when adding columns, changing unique constraints, creating indexes, fixing migration errors, writing repeatable migration scripts, or moving data between databases.
Why use it?
Database changes can leave missing columns, broken constraints, or partly moved data. This provides a controlled process for schema changes and data transfers.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/seed-forge/harness-ai-kit/devlab-db-data-migration
Any agent
npx skills add seed-forge/harness-ai-kit --skill devlab-db-data-migration
Clone the repo
git clone --depth 1 https://github.com/seed-forge/harness-ai-kit

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for devlab-db-data-migration

README.md
[![agentmods](https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/devlab-db-data-migration.svg)](https://agentmods.dev/skills/seed-forge/harness-ai-kit/devlab-db-data-migration)
Your own site
<a href="https://agentmods.dev/skills/seed-forge/harness-ai-kit/devlab-db-data-migration"><img src="https://agentmods.dev/badge/skills/seed-forge/harness-ai-kit/devlab-db-data-migration.svg" alt="Measured on agentmods" height="20"></a>
Per session 165 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,327 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00165 $0.01327
Opus 5 $0.00082 $0.00664
Sonnet 5 $0.00033 $0.00265
Haiku 4.5 $0.00016 $0.00133

Measured 3d ago against content hash 40287d2b70ea, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

devlab-db-data-migration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/sqlite_safe_migration.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/devlab-db-data-migration/SKILL.md · 87 lines

How it starts

The opening of the file, as written. The whole thing — 87 lines — stays where its author put it; the contents beside it link to each section on GitHub.

devlab-db-data-migration

用途

数据库数据层安全迁移:当已有表需要加列、改约束、建索引或搬迁数据时,提供一条"绝不留半迁移状态"的安全流程。源自真实生产修复(33/33 测试通过 + 生产库迁移成功)。

定位:与 devlab-dao-sql-compat(SQL 语法兼容层)正交互补——一个管"语法怎么写才兼容",一个管"数据怎么迁才安全"。

适用场景

  • 已有表结构演进:加列、改唯一约束、补索引。
  • 生产环境报 no such column / 唯一约束冲突。
  • 需要编写可重复执行、可回滚的独立迁移脚本。
  • 跨库数据搬迁需要行数对账。

不适用场景

  • SQL 语法跨方言兼容问题(用 devlab-dao-sql-compat)。
  • 组织内部集群 应用级迁移(用 组织内部集群-app-migration,非数据层)。
  • 全新建表(无历史数据,直接建即可)。

通用五步流程(所有数据库通用)

  1. 备份:迁移前备份(文件库复制 .bak;服务端库 dump 或快照),记录备份位置。
  2. 幂等检测:先探测目标结构是否已存在(列/索引/约束),已迁移则退出 0——保证脚本可重复执行。
  3. 迁移执行(顺序硬约束):
    • 加列必须先于任何引用新列的 CREATE INDEX / 回填 UPDATE。
    • 约束变更评估该方言是否支持在线 ALTER,不支持则走重建表路径。
    • 索引对齐/去重必须在改名、补列、回填、legacy 合并全部完成之后。
  4. 迁移后验证:schema 断言(结构符合预期)+ 行数对账(旧表 == 新表)+ 全量测试回归。
  5. 失败自动恢复:任一步异常 → 从备份恢复 → 退出非 0,绝不留半迁移状态

方言分支

SQLite

  • ALTER TABLE 仅支持加列/改名;UNIQUE 约束不可 ALTER,只能四步重建: CREATE TABLE new_xINSERT INTO new_x SELECT ...DROP TABLE xRENAME TO x(重建后补全部索引)。
  • 探测用 PRAGMA table_info / PRAGMA index_list
  • 陷阱:CREATE TABLE IF NOT EXISTS 不会更新已存在表的列与约束。

MySQL(Flyway/Liquibase 场景)

  • 版本化脚本内做幂等:information_schema 探测 + 动态 SQL 条件执行。
  • 大表 DDL 评估 online DDL / pt-osc;重建表路径同样适用约束不兼容场景。

工程约定

  • 开发环境可用代码内自动迁移(嵌入 init);生产必须独立迁移脚本(有备份/dry-run/回滚/审计)。
  • CLI 约定:--db <path> / --dry-run / --rollback
  • 验收标准:迁移后全量测试绿 + 实际库 schema 验证通过。

附带 tool

  • scripts/sqlite_safe_migration.py — Python 单文件模板(备份/幂等/重建/验证/回滚骨架已固化,按具体迁移填充 MIGRATION 区)。

Notes:迁移脚本编辑纪律

编辑顺序敏感的迁移脚本时:连续 2 次 patch 失败/overlap 即熔断——停止增量修改, 全量重读文件 + grep 关键锚点定位,单次精准 patch 后 grep 校验锚点唯一且位置正确。

根因:多次改动后锚点漂移,基于"记忆中的旧版本"继续 patch 必然错位。

与其他 Skill 的关系

Skill 关系
devlab-dao-sql-compat 正交互补:语法层 vs 数据层
public-mysql-expert-base 知识库上游(schema 设计知识)
devlab-srv-reliability-ops / infra-reliability-ops 迁移失败根因诊断(研发服务/基础设施)
组织内部集群-app-migration 无关(应用级迁移,非数据层)

推荐触发方式

用 devlab-db-data-migration 帮我给这张表加唯一约束,SQLite 的,要安全可回滚

Read the full file on GitHub · 87 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 87 lines · 165 tokens per session scan A 40287d2b70ea

Subscribe to this mod's changes

devlab-db-data-migration is a skill published in the GitHub repository seed-forge/harness-ai-kit (21 stars, last pushed 6d ago), licensed Apache-2.0. It adds 165 tokens to every session and 1,327 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

deprecation-and-migration

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset…

addyosmani/agent-skills · 69 tokens

cloudbase-document-database-web-sdk

Use CloudBase document database Web SDK only for confirmed NoSQL collection work. Query, create, update, and delete document data; if the task mentions PostgreSQL / CloudBase PG / app.rdb(), route to postgresql-development instead.

TencentCloudBase/CloudBase-AI-Toolkit · 55 tokens

relational-database-mcp-cloudbase

Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../auth-tool-cloudbase/SKILL.md.

TencentCloudBase/CloudBase-AI-Toolkit · 94 tokens

cloudbase-document-database-in-wechat-miniprogram

Use CloudBase document database WeChat MiniProgram SDK to query, create, update, and delete data. Supports complex queries, pagination, aggregation, and geolocation queries.

TencentCloudBase/CloudBase-AI-Toolkit · 46 tokens

relational-database-web-cloudbase

Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../auth-tool-cloudbase/SKILL.md.

TencentCloudBase/CloudBase-AI-Toolkit · 68 tokens

backend-development

Backend API design, database architecture, microservices patterns, and test-driven development. Use for designing APIs, database schemas, or backend system architecture.

MoizIbnYousaf/Ai-Agent-Skills · 32 tokens