Skip to content
Agentmart
Submit a tool

create-migration

Applies only to work in the quantum-box/tachyon-apps repository.

Skill by quantum-box

IndexedMIT
Write a review

Chalk Labs

Need help deploying create-migration?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/quantum-box-create-migration

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Applies only to work in the quantum-box/tachyon-apps repository. Create TiDB-compatible SQLx migration files. Use proactively when: (1) New database table needs to be created, (2) Existing table schema needs modification (ADD/DROP/MODIFY COLUMN), (3) Index addition or removal needed, (4) Task involves database schema changes. Ensures TiDB DDL compatibility and follows project conventions.

Use cases: backend, productivity

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/create-migration

What's inside

Skill name
create-migration
Description
Applies only to work in the quantum-box/tachyon-apps repository. Create TiDB-compatible SQLx migration files. Use proactively when: (1) New database table needs to be created, (2) Existing table schema needs modification (ADD/DROP/MODIFY COLUMN), (3) Index addition or removal needed, (4) Task involves database schema changes. Ensures TiDB DDL compatibility and follows project conventions.
License
MIT
Instructions
319 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Create TiDB-Compatible Migration

TiDB互換のSQLxマイグレーションファイルを作成するスキル。

## TiDB DDL 重要制約

TiDBはMySQL互換だが、DDLに関して以下の重要な違いがある。**これらを理解せずにマイグレーションを書くとデプロイ時に失敗する。**

### 1. DDLは自動コミット(最重要)

TiDBではDDLステートメントは暗黙的にトランザクションをコミットする。**DDLとDMLを同一トランザクション/マイグレーションファイルに混在させてはならない。**

```sql
-- ❌ NG: DDL + DML を同じマイグレーションに書く
CREATE TABLE `new_table` (...);
INSERT INTO `new_table` VALUES (...);  -- DDLの自動コミット後に実行され、ロールバック不可

-- ❌ NG: ALTER TABLE 後に UPDATE
ALTER TABLE `users` ADD COLUMN `role` VARCHAR(20) DEFAULT 'user';
UPDATE `users` SET `role` = 'admin' WHERE `id` = 'us_xxx';  -- 同上

-- ✅ OK: DDLのみをマイグレーションに書く
ALTER TABLE `users` ADD COLUMN `role` VARCHAR(20) NOT NULL DEFAULT 'user';
-- データ投入はシードファイル(yaml-seeder)で行う
```

### 2. ADD COLUMNの制約

```sql
-- ✅ サポートされる
ALTER TABLE t ADD COLUMN col1 INT;
ALTER TABLE t ADD COLUMN IF NOT EXISTS col1 INT;
ALTER TABLE t ADD COLUMN col1 INT AFTER existing_col;
ALTER TABLE t ADD COLUMN col1 INT FIRST;
ALTER TABLE t ADD COLUMN col1 INT, ADD COLUMN col2 VARCHAR(50);  -- v6.2.0+

-- ❌ サポートされない
ALTER TABLE t ADD COLUMN col1 INT PRIMARY KEY;        -- 新カラムをPKに設定不可
ALTER TABLE t ADD COLUMN col1 INT AUTO_INCREMENT;     -- 新カラムをAUTO_INCREMENTに設定不可

-- ❌ 同じALTER内で新カラムをAFTERで参照不可
ALTER TABLE t ADD COLUMN c1 INT, ADD COLUMN c2 INT AFTER c1;  -- c1はまだ存在しないためエラー
-- ✅ 別のALTER文に分ける
ALTER TABLE t ADD COLUMN c1 INT;
ALTER TABLE t ADD COLUMN c2 INT AFTER c1;
```

### 3. Multi-Schema Change(v6.2.0+)

単一のALTER TABLEで複数の操作が可能。ただし**同じオブジェクトを複数回変更することは不可**。

```sql
-- ✅ OK: 異なるカラムを同時に操作
ALTER TABLE `t`
  ADD COLUMN `a` INT,
  ADD COLUMN `b` VARCHAR(50),
  DROP COLUMN `c`;

-- ❌ NG: 同じカラムを複数回変更
ALTER TABLE `t`
  ADD COLUMN `a` INT,
  MODIFY COLUMN `a` BIGINT;  -- 同じカラム `a` を2回変更
```

### 4. DROP COLUMNの制約

```sql
-- ✅ サポートされる
ALTER TABLE t DROP COLUMN col1;
ALTER TABLE t DROP COLUMN IF EXISTS col1;

-- ❌ サポートされない
-- PKカラムのDROPは不可
-- 複合インデックスに含まれるカラムのDROPは不可(インデックスを先に削除する)
-- ビューやエクスプレッションインデックスから参照されているカラムのDROPは不可

-- ❌ 複数カラムの同時DROPは不可
ALTER TABLE t DROP COLUMN col1, DROP COLUMN col2;  -- エラー: can't run multi schema change
-- ✅ 別々のALTER文に分ける
ALTER TABLE t DROP COLUMN col1;
ALTER TABLE t DROP COLUMN col2;
```

### 5. MODIFY COLUMN の制約

```sql
-- ✅ サポートされる: 型の拡大(INT→BIGINT)、NULLable化、デフォルト値変更、COMMENT変更
ALTER TABLE t MODIFY COLUMN col1 BIGINT;
ALTER TABLE t MODIFY COLUMN col1 VARCHAR(100) NULL;

-- ⚠️ 制限付き: 型変更はLossy Column Type Change(データロスの可能性)
--   INTEGER型同士の変更は可能(INT→BIGINT等)
--   VARCHAR長の拡大は可能
--   VARCHAR→TEXT等の互換性のない変更は要注意
```

### 6. ADD INDEX のパフォーマンス影響

ADD INDEXはオンライン操作だが、**書き込み負荷の高い本番環境では性能に影響する**。

- 状態遷移: `absent → delete only → write only → write reorg → public`
- `write reorg`フェーズでバックフィルが発生し、TiKVのCPU/IOを消費
- 書き込みが多いカラムへのインデックス追加はTPSが大幅に低下する可能性あり

**本番での対策:**
```sql
-- インデックス作成の並列度を下げる(デフォルトの1/8)
SET @@global.tidb_ddl_reorg_worker_cnt = 4;
SET @@global.tidb_ddl_reorg_batch_size = 256;
```

### 7. テーブル置き換えパターン(大規模スキーマ変更)

PKの変更やカラム位置の大幅変更には「テーブル置き換え」パターンを使用する。

```sql
-- 1. 新テーブル作成
CREATE TABLE `users__new` (
    `id` VARCHAR(29) NOT NULL,

From quantum-box/tachyon-skills, MIT.

More from quantum-box/tachyon-skills

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Sep 29, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from quantum-box

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get create-migration running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying create-migration?

CallGet help
Cite this page

create-migration skill. Agent Mart. https://agentmart.dev/skills/quantum-box-create-migration (last updated 2026-10-24)