Agent skill

Database Migration

by Rain-kl in Rain-kl/OpenFlare

Wavelet 项目专用:当新增或修改数据库表结构、索引、初始化数据、系统配置 seed、模板 seed、默认管理员、goose SQL 迁移、internal/infra/persistence/migrator、ClickHouse 分析库 DDL 或数据库升级流程时必须使用。本技能指导在 internal/infra/persistence/migrator/goose 下编写…

Apache-2.0Auto-check passedDatabases

Install Database Migration

skills CLI
$ npx skills add Rain-kl/OpenFlare --skill database-migration -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Rain-kl/OpenFlare database-migration --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Rain-kl/OpenFlare.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/database-migration .claude/skills/database-migration && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
database-migration
GitHub stars
288
Token cost
~1.3k tokens
SKILL.md length
379 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
Apache-2.0

At a glance

Wavelet 项目专用:当新增或修改数据库表结构、索引、初始化数据、系统配置 seed、模板 seed、默认管理员、goose SQL 迁移、internal/infra/persistence/migrator、ClickHouse 分析库 DDL 或数据库升级流程时必须使用。本技能指导在 internal/infra/persistence/migrator/goose 下编写…

  • Works in 7 steps: 先确认涉及的 Go model、读写路径和前端/接口消费方。 → 选择下一个递增版本号,格式建议 YYYYMMDDNNNN,例如 → 在 PostgreSQL 和 SQLite 目录各新增同名 SQL 文件。 → …
  • Tasks that involve Data warehousing
  • SKILL.md covers 基本规则, 新增迁移流程, 方言注意事项 and 修改默认系统配置, plus 2 more sections
  • Calls go and make

What it does

Database Migration is an agent skill from Rain-kl/OpenFlare. Wavelet 项目专用:当新增或修改数据库表结构、索引、初始化数据、系统配置 seed、模板 seed、默认管理员、goose SQL 迁移、internal/infra/persistence/migrator、ClickHouse 分析库 DDL 或数据库升级流程时必须使用。本技能指导在 internal/infra/persistence/migrator/goose 下编写 PostgreSQL/SQLite 双方言 SQL 迁移,以及在 goose/clickhouse 下编写 ClickHouse 单方言分析表迁移,并完成验证。

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Data warehousing, Database migrations and SQL. It works with ClickHouse, SQL, PostgreSQL and SQLite. The repository describes itself as: OpenFlare is an open-source CDN orchestration and edge security platform. It supports reverse proxy, centralized configuration synchronization, in-network tunneling (Tunnels)… The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Data warehousing
  • Tasks that involve Database migrations
  • Tasks that involve SQL

Example prompts

  • “/database-migration”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. 先确认涉及的 Go model、读写路径和前端/接口消费方。
  2. 选择下一个递增版本号,格式建议 YYYYMMDDNNNN,例如
  3. 在 PostgreSQL 和 SQLite 目录各新增同名 SQL 文件。
  4. 写 Up
  5. 写 Down
  6. 如果变更 API handler,运行 make swagger。
  7. 至少运行

What it can do on your machine

Read from SKILL.md and the folder at commit 7483897. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • go
    • make

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Database Migration loads about 1.3k tokens when it runs. Until then it costs about 73 tokens; SKILL.md has 379 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~73
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Rain-kl/OpenFlare at commit 7483897, republished under its Apache-2.0 licence (© Rain-kl). 379 words, ~1,258 tokens.

Download SKILL.mdSave it as .claude/skills/database-migration/SKILL.md (or your agent's skills folder).
name
database-migration
description
Wavelet 项目专用:当新增或修改数据库表结构、索引、初始化数据、系统配置 seed、模板 seed、默认管理员、goose SQL 迁移、internal/infra/persistence/migrator、ClickHouse 分析库 DDL 或数据库升级流程时必须使用。本技能指导在 internal/infra/persistence/migrator/goose 下编写 PostgreSQL/SQLite 双方言 SQL 迁移,以及在 goose/clickhouse 下编写 ClickHouse 单方言分析表迁移,并完成验证。

Wavelet 数据库升级操作指南

Wavelet 使用 github.com/pressly/goose/v3 执行 SQL 迁移。迁移入口是 internal/infra/persistence/migrator.Migrate(),SQL 文件嵌入在二进制中。

基本规则

  • SQL 迁移文件放在:
    • internal/infra/persistence/migrator/goose/postgres/
    • internal/infra/persistence/migrator/goose/sqlite/
  • PostgreSQL 和 SQLite 必须使用同一个版本号、同一个语义文件名。
  • 迁移文件使用 goose SQL 标记:
sql
-- +goose Up
...

-- +goose Down
...
  • 不要把表结构、默认系统配置、默认模板、默认管理员初始化写回 Go 代码。
  • 编辑表结构(DDL)和插入表数据(DML/Seed)不要放在同一个 SQL 文件里,必须分成两个独立的 SQL 文件完成(例如,先通过一个文件修改表结构,再通过下一个递增版本号的文件插入/初始化数据)。
  • 插入定时任务(schedules 表数据)时绝对不能指定 id,必须依靠数据库自增(Identity 或 AUTOINCREMENT)自动分配,防止与用户手动或后续插入的定时任务产生 ID 冲突。
  • 不要添加物理外键;关系字段使用显式索引。
  • 数据库默认值应匹配 Go model 零值或业务兜底值。
  • 系统配置仍然保存字符串值;布尔值写 "true" / "false",数字写十进制字符串,复杂结构写合法 JSON 字符串。

新增迁移流程

  1. 先确认涉及的 Go model、读写路径和前端/接口消费方。
  2. 选择下一个递增版本号,格式建议 YYYYMMDDNNNN,例如:
text
202606090002_add_example_column.sql
  1. 在 PostgreSQL 和 SQLite 目录各新增同名 SQL 文件。
  2. 写 Up:
    • 表结构变更使用 SQL DDL。
    • 初始化/seed 数据使用 SQL INSERT。
    • 需要幂等时使用 IF NOT EXISTS 或 ON CONFLICT ... DO NOTHING。
  3. 写 Down:
    • 能安全回滚的结构变更写反向 DDL。
    • seed 数据按 key/name 等稳定标识删除。
  4. 如果变更 API handler,运行 make swagger。
  5. 至少运行:
bash
go test ./internal/infra/persistence/migrator
go test ./internal/model ./internal/apps/config ./internal/apps/admin/system_config
make code-check

方言注意事项

  • PostgreSQL 自增主键用 BIGSERIAL;SQLite 自增主键用 INTEGER PRIMARY KEY AUTOINCREMENT。
  • PostgreSQL 时间类型优先 TIMESTAMPTZ;SQLite 使用 DATETIME。
  • PostgreSQL JSON 字段用 JSONB;SQLite 用 JSON 或 TEXT。
  • 两个方言目录的字段名、索引名、seed 数据语义必须保持一致。

修改默认系统配置

  • 新增或调整系统配置 seed 时,更新两个方言的 SQL 文件。
  • visibility 使用常量语义:0 不公开,1 通过 /api/v1/config/public 返回。
  • 公共配置 API 直接返回所有 visibility = 1 的配置键值,不要在 handler 中重新硬编码 key 列表。

验证重点

  • goose 能在空库上完整执行。
  • system_configs、默认 admin、内置模板能按预期初始化。
  • 新增表/列与 Go model 的列名、类型和默认值兼容。
  • 前端或接口消费的公共配置值仍按字符串解析。

ClickHouse 分析库(辅助 OLAP)

ClickHouse 是辅助 OLAP 存储,与 PostgreSQL/SQLite 主库完全独立的迁移与访问管线:

  • 主库(PG/SQLite):业务事务数据、goose_db_version、双方言 SQL。
  • 分析库(ClickHouse):分析型数据、goose_clickhouse_version、单方言 SQL。日志用途表还必须在主库建回落并走 logstore(见该 skill);CH 目录仍只放 CH DDL。

不要把 ClickHouse 表结构混入 PG/SQLite 迁移目录,也不要在 support-files/、internal/apps/ 或 internal/repository/ 中手写 DDL。

目录与职责
路径职责
internal/infra/persistence/migrator/goose/clickhouse/唯一 ClickHouse DDL 来源(goose SQL,嵌入二进制)
internal/model/analytics/分析表 Go model,列名须与 goose DDL 一致
internal/repository/analytics/所有 ClickHouse 读写(批量写入、查询、聚合)
internal/infra/persistence/clickhouse.go连接初始化(ChConn 原生批量、ChDB GORM 查询)
迁移入口与版本表
  • 入口:migrator.MigrateClickHouse(),在 cmd/root.go 的 PreRun 中于 migrator.Migrate() 之后调用。
  • 仅当 clickhouse.enabled: true 时执行;禁用时直接跳过(见 TestMigrateClickHouseSkipsWhenDisabled)。
  • 版本表:goose_clickhouse_version,与主库 goose_db_version 分离,互不影响。
  • 方言:仅 ClickHouse,无 SQLite 镜像目录。
Show full SKILL.md (150 more words)Show less
ClickHouse 迁移规则
  1. DDL 只写 goose SQL:CREATE TABLE IF NOT EXISTS ...,禁止 GORM AutoMigrate、禁止在 repository 或 handler 中建表。
  2. 无事务:ClickHouse 不支持 goose 事务包装;每个 Up/Down 语句独立提交。
  3. 幂等 Up:表用 IF NOT EXISTS;Down 用 DROP TABLE IF EXISTS。
  4. Down 谨慎:MergeTree 等引擎上 DROP TABLE 会立即删除数据,生产环境通常只前滚;仅在开发/测试需要回滚时编写 Down。
  5. DDL 与 DML 分离:与主库相同,表结构变更与数据初始化分文件、分版本号;分析表通常无 seed,批量写入由 repository 在运行时完成。
  6. 引擎与排序键:在 SQL 中显式声明 ENGINE、PARTITION BY、ORDER BY 等,与查询模式对齐(例如按 created_at 分区)。
  7. 禁止重复 DDL:不要在 support-files/、apps 初始化逻辑或 repository/analytics 中复制建表语句。
新增分析表工作流

按以下顺序落地,避免列名或类型漂移:

  1. Model:在 internal/model/analytics/ 定义 struct,gorm:"column:..." 与 DDL 列名一一对应;实现 TableName(),批量写入表可提供 InsertColumns() / BatchInsertSQL()。
  2. Goose SQL:在 internal/infra/persistence/migrator/goose/clickhouse/ 新增递增版本文件(格式同主库,如 YYYYMMDDNNNN_create_xxx.sql),编写 -- +goose Up / -- +goose Down。
  3. Repository:在 internal/repository/analytics/ 实现 BatchInsert*(db.ChConn 一次 PrepareBatch + 多行 Append + 一次 Send)与查询(db.ChDB);连接未初始化时返回明确错误,不要在 handler 写 SQL,不要在 repository 内维护 channel/goroutine。
  4. Apps:在 internal/apps/<domain>/ 编排采集与入队;高频写入通过 internal/infra/persistence/batchwriter 各域独立实例异步 flush(详见 clickhouse-batchwriter 技能)。日志/分析用途表还要同时建 PG/SQLite 回落并接入 logstore(见 logstore 技能),FlushFunc 调 logstore.Active 而不是 analyticsrepo;普通业务分析表仍只读 repository。
ClickHouse 验证

至少运行:

bash
go test ./internal/infra/persistence/migrator
go test ./internal/repository/analytics
make code-check

验证重点:

  • goose 能在空 ClickHouse 实例上完整执行 Up。
  • internal/model/analytics 列名、类型与 goose SQL 一致。
  • repository 读写路径不依赖 handler 内联 SQL。
  • clickhouse.enabled: false 时启动不报错、不执行迁移。

© Rain-kl, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/database-migration of Rain-kl/OpenFlare.

Open the folder on GitHubat commit 7483897

Compare with similar skills

Database Migration next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Database Migration compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Database Migration this skillRain-kl/OpenFlare288—~1.3kAutomated safety check: PassApache-2.0
Chdb SQLvemetric/vemetric3941 repos~1.2kAutomated safety check: PassApache-2.0
Querying Tempotempoxyz/tidx107—~3.1kAutomated safety check: PassMIT
Semantic Analystsidequery/sidemantic129—~982Automated safety check: PassAGPL-3.0
Database MarchatCod-e-Codes/marchat137—~985Automated safety check: PassMIT
Warehouse SQLHybridAIOne/hybridclaw158—~1.8kAutomated safety check: PassMIT

Similar skills

  • Chdb SQL

    vemetric/vemetric

    A skill your agent uses when the user wants to run SQL — especially analytical SQL — on local files (parquet/csv/json), URLs, S3 paths, or remote databases (Postgres, MySQL, MongoDB, ClickHouse…

    394 GitHub starsUsed in 1 repo~1.2k tokens
    DatabasesAuto-check passed
  • Querying Tempo

    tempoxyz/tidx

    Query indexed Tempo chain data via tidx HTTP API and CLI. An agent skill from tempoxyz/tidx.

    107 GitHub stars~3.1k tokensUpdated today
    DatabasesAuto-check passed
  • Semantic Analyst

    sidequery/sidemantic

    Answer analytical, KPI, metric, trend, cohort, and business-performance questions through a Sidemantic semantic layer.

    129 GitHub stars~982 tokensUpdated today
    DatabasesAuto-check passed
  • Database Marchat

    Cod-e-Codes/marchat

    Changes marchat SQL schema and queries across SQLite, PostgreSQL, and MySQL using dialect helpers.

    137 GitHub stars~985 tokensUpdated 4 days ago
    DatabasesAuto-check passed
  • Warehouse SQL

    HybridAIOne/hybridclaw

    Review and run read-only natural-language SQL against a customer data warehouse with cached schema introspection and explicit write grants.

    158 GitHub stars~1.8k tokensUpdated today
    DatabasesAuto-check passed
  • Gram Demo Seed

    speakeasy-api/gram

    A skill your agent uses when adding a new feature or changing an existing one that surfaces data in the dashboard — the demo org (app.getgram.ai/explore-demo) must show it — and when editing or…

    272 GitHub stars~2.5k tokensUpdated today
    DatabasesAuto-check passed

More from Rain-kl/OpenFlare

All 12 skills in this repo
  • Code Review Skill

    Rain-kl/OpenFlare

    Provides comprehensive code review guidance for React 19, Vue 3, Angular 17+, Svelte 5, Rust, TypeScript, Java, PHP, Python, Django, Go, C/.NET, Kotlin, Swift, NestJS, C/C++, and more.

    288 GitHub stars~2.3k tokensUpdated today
    Auto-check: notes
  • Go Logging

    Rain-kl/OpenFlare

    在选择日志方案、配置 slog、编写结构化日志语句或决定日志级别时使用。也适用于设置生产日志、为日志添加请求作用域上下文或从 log 迁移到 slog 的场景,即使用户未明确提及日志。不涵盖错误处理策略(参见 go-error-handling)。

    288 GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • New API

    Rain-kl/OpenFlare

    Wavelet 项目专用:当新增或修改自定义业务 API、新增业务路由、新增 service 层核心逻辑时必须使用。本技能指导包职责划分、推荐文件结构、路由解耦、Swagger 文档生成与质量门禁验证。

    288 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Cache Framework

    Rain-kl/OpenFlare

    Wavelet 项目专用:当新增或修改业务缓存(RAM/Redis/DB 三层读路径)、缓存失效、多节点 pub/sub 同步、或评估高频读是否应接入缓存时必须使用。本技能说明系统标准缓存框架、参考实现、禁止写法与分布式一致性要求。

    288 GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Clickhouse Batchwriter

    Rain-kl/OpenFlare

    Wavelet 项目专用:当新增或修改 ClickHouse 批量写入、接入 internal/infra/persistence/batchwriter、将业务域异步 flush 到分析表、迁移 riskcontrol/节点访问日志/可观测时序写入、或评估 asyncinsert 与背压策略时必须使用。本技能指导分层职责、各域独立 Writer 实例、repository 批量 API…

    288 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • File Upload

    Rain-kl/OpenFlare

    Wavelet 项目专用:当业务需要上传文件、读取已上传文件、在 Worker/任务中程序化摄取字节流、选择存储引擎能力、或排查 wuploads / 文件统计异常时必须使用。本技能指导 storage 与 upload 分层、upload.Ingest 策略选型、前后端接入与禁止旁路写表。

    288 GitHub stars~1.7k tokensUpdated today
    Auto-check passed

Categories

Questions about Database Migration

What does Database Migration do?

Wavelet 项目专用:当新增或修改数据库表结构、索引、初始化数据、系统配置 seed、模板 seed、默认管理员、goose SQL 迁移、internal/infra/persistence/migrator、ClickHouse 分析库 DDL 或数据库升级流程时必须使用。本技能指导在 internal/infra/persistence/migrator/goose 下编写…. Database Migration is an agent skill from Rain-kl/OpenFlare.

When should I use Database Migration?

Database Migration fits situations like: tasks that involve Data warehousing; tasks that involve Database migrations; tasks that involve SQL.

How do I install Database Migration in Claude Code?

Run `npx skills add Rain-kl/OpenFlare --skill database-migration -a claude-code`. Or copy the skill folder (.agents/skills/database-migration in Rain-kl/OpenFlare) into .claude/skills/database-migration in your project. Claude Code loads it when a task matches its description.

How do I install Database Migration in Codex?

Run `npx skills add Rain-kl/OpenFlare --skill database-migration -a codex`. Or copy the skill folder (.agents/skills/database-migration in Rain-kl/OpenFlare) into .agents/skills/database-migration in your project. Codex loads it when a task matches its description.

Can I use Database Migration in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Rain-kl/OpenFlare --skill database-migration -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/database-migration, .gemini/skills/database-migration, .github/skills/database-migration and .opencode/skills/database-migration in your project.

What does Database Migration need to run?

Going by SKILL.md and its folder, Database Migration needs the command-line tools its instructions call (go and make).

Does Database Migration access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Database Migration safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Database Migration use?

Database Migration is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Database Migration use?

About 1.3k tokens (SKILL.md is roughly 5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Database Migration?

Skills that share tags, products or a category with Database Migration: Chdb SQL (vemetric/vemetric, 394 stars), Querying Tempo (tempoxyz/tidx, 107 stars), Semantic Analyst (sidequery/sidemantic, 129 stars) and Database Marchat (Cod-e-Codes/marchat, 137 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Database Migration?

Rain-kl (a GitHub user) maintains it in Rain-kl/OpenFlare, which has 288 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 7, 2026.

Source: Rain-kl/OpenFlare on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.