---
name: migrate-validate
description: Validate pending migrations for foreign key consistency, rollback safety, and best practices
argument-hint: ""
allowed-tools: Read Glob Grep Bash mcp__claude-flow__memory_search mcp__claude-flow__memory_list mcp__claude-flow__memory_store mcp__claude-flow__agentdb_pattern-store mcp__claude-flow__agentdb_semantic-route
---

# Migrate Validate

Validate all pending database migrations for correctness, safety, and adherence to best practices.

## When to use

Before applying migrations to catch issues early -- foreign key references to non-existent tables, missing rollback SQL, destructive operations without safeguards, and naming convention violations.

## Steps

1. **Find pending migrations** -- use `Glob` to list all migration files, cross-reference with applied history via `mcp__claude-flow__memory_search --namespace migrations` (or `memory_list`) to identify pending ones. The `memory_*` tool family routes by namespace; `agentdb_hierarchical-*` does NOT (it routes by tier), so use `memory_*` here.
2. **Parse SQL** -- use `Read` to load each pending `.up.sql` and `.down.sql` file and parse the SQL statements
3. **Check foreign keys** -- verify that all REFERENCES targets exist in the current schema or in prior migrations (both applied and pending)
4. **Check NOT NULL defaults** -- verify that any ADD COLUMN with NOT NULL has a DEFAULT value
5. **Check rollback completeness** -- verify every CREATE/ALTER in the UP file has a corresponding DROP/ALTER in the DOWN file
6. **Flag destructive ops** -- warn on DROP TABLE, DROP COLUMN, TRUNCATE without explicit confirmation
7. **Check idempotency** -- verify IF EXISTS / IF NOT EXISTS is used for safety
8. **Check naming** -- verify table names are plural, column names are snake_case, index names follow `idx_table_column` convention
9. **Store validation patterns** -- two paths (per ruflo-cost-tracker ADR-0001 dual-path pattern):
   - **Pattern store (typed, recommended)**: `mcp__claude-flow__agentdb_pattern-store` with `type: 'migration-validation'`. No namespace arg — ReasoningBank routes it.
   - **Plain store (namespace-routable)**: `mcp__claude-flow__memory_store --namespace migrations` for validation results tied to a specific migration number.
10. **Report** -- display: errors (must fix), warnings (should fix), info (suggestions), with file path and line number for each issue

## CLI alternative

```bash
npx @claude-flow/cli@latest memory search --query "migration validation results" --namespace migrations
```


---
Source attribution: wodeh
Original project: https://github.com/wodeh/ruflo-kimi/blob/257ccb7e80a2619f8af236554ae6f0ca362abfa6/plugins/ruflo-migrations/skills/migrate-validate/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2024-2026 ruvnet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: wodeh
Original project: https://github.com/wodeh/ruflo-kimi/blob/257ccb7e80a2619f8af236554ae6f0ca362abfa6/plugins/ruflo-migrations/skills/migrate-validate/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering
Roles: Backend Developer, Database Administrator, DevOps / SRE
Specialties: Database
Tools: Bash, Glob, Grep, Mcp__Claude Flow__Agentdb_Pattern Store, Mcp__Claude Flow__Agentdb_Semantic Route, Mcp__Claude Flow__Memory_List, Mcp__Claude Flow__Memory_Search, Mcp__Claude Flow__Memory_Store
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 48cdf9ed045b8997c00aad29623f5769c8cb2a58d62580a365c70ad8af74857d
