Get the FREE Ultimate OpenClaw Setup Guide →

schema-comparator

npx machina-cli add skill a5c-ai/babysitter/schema-comparator --openclaw
Files (1)
SKILL.md
2.5 KB

Schema Comparator Skill

Compares database schemas between source and target environments to identify differences and generate migration scripts.

Purpose

Enable database migration planning for:

  • Schema diff generation
  • Data type mapping
  • Constraint comparison
  • Index analysis
  • Migration script generation

Capabilities

1. Schema Diff Generation

  • Compare table structures
  • Identify column differences
  • Detect missing objects
  • Generate change reports

2. Data Type Mapping

  • Map types across databases
  • Handle type conversions
  • Identify precision changes
  • Document compatibility

3. Constraint Comparison

  • Compare primary keys
  • Analyze foreign keys
  • Check unique constraints
  • Verify check constraints

4. Index Analysis

  • Compare index definitions
  • Identify missing indexes
  • Analyze index usage
  • Recommend optimizations

5. Stored Procedure Comparison

  • Compare procedure signatures
  • Identify logic differences
  • Detect parameter changes
  • Flag deprecated procedures

6. Migration Script Generation

  • Generate DDL scripts
  • Create rollback scripts
  • Handle dependencies
  • Order changes correctly

Tool Integrations

ToolDatabasesIntegration Method
FlywayMultiCLI
LiquibaseMultiCLI
Redgate SQL CompareSQL ServerCLI
SchemaHeroKubernetesCLI
pgdiffPostgreSQLCLI
mysqldiffMySQLCLI

Output Schema

{
  "comparisonId": "string",
  "timestamp": "ISO8601",
  "source": {
    "type": "string",
    "connection": "string"
  },
  "target": {
    "type": "string",
    "connection": "string"
  },
  "differences": {
    "tables": {
      "added": [],
      "removed": [],
      "modified": []
    },
    "columns": [],
    "constraints": [],
    "indexes": [],
    "procedures": []
  },
  "migration": {
    "scripts": [],
    "order": [],
    "rollback": []
  }
}

Integration with Migration Processes

  • database-schema-migration: Primary comparison tool
  • data-format-migration: Schema analysis

Related Skills

  • data-migration-validator: Post-migration validation
  • query-translator: SQL conversion

Related Agents

  • database-migration-orchestrator: Uses for planning
  • data-architect-agent: Schema design review

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/code-migration-modernization/skills/schema-comparator/SKILL.mdView on GitHub

Overview

Compares source and target database schemas to identify differences and generate migration scripts. It covers diff generation, data type mapping, constraint and index analysis, and stored procedure comparison to support safe migration planning.

How This Skill Works

The skill analyzes both source and target schemas to produce diffs across tables, columns, constraints, indexes, and procedures. It then maps data types, handles precision changes, and generates DDL scripts plus rollback scripts, ordering changes to respect dependencies and integrating with common migration tools.

When to Use It

  • Before migrating databases to identify schema differences and generate a baseline migration plan
  • When migrating across heterogeneous databases to map data types and preserve compatibility
  • To validate constraints, indexes, and procedure signatures between environments
  • When planning deployment order to satisfy dependency constraints during migration
  • When producing migration scripts and rollback scripts for audit and safety checks

Quick Start

  1. Step 1: Connect source and target database schemas in the comparator
  2. Step 2: Run the schema diff to generate differences across tables, columns, constraints, indexes, and procedures
  3. Step 3: Review diffs and export migration scripts plus rollback scripts, then apply with your chosen migration tool

Best Practices

  • Establish a known baseline in both source and target environments before diffing
  • Diff all object types (tables, columns, constraints, indexes, procedures) for completeness
  • Verify data type mappings and precision changes across databases
  • Review the proposed change order to respect dependencies and avoid failures
  • Test generated DDL and rollback scripts in a staging environment prior to production

Example Use Cases

  • Migrate from MySQL to PostgreSQL by diffing schemas, mapping types, and generating DDL with rollback scripts
  • Refactor an application schema and compare constraints and stored procedures to ensure parity
  • Identify missing indexes and generate optimization scripts for a performance-focused migration
  • Synchronize stored procedure signatures across environments and flag deprecated procedures
  • Produce end-to-end migration scripts using Flyway or Liquibase with proper dependency order

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers