---
name: schema-comparator-d755d47e8a42
description: Compare database schemas between source and target environments for migration planning
allowed-tools: ["Bash", "Read", "Write", "Grep", "Glob", "Edit"]
graph:
  domains: [domain:software-engineering]
  specializations: [specialization:code-migration-modernization]
  skillAreas: [skill-area:schema-evolution, skill-area:database-migrations-zero-downtime]
  roles: [role:data-engineer, role:backend-engineer]
  workflows: [workflow:technical-debt-reduction]
  topics: [topic:refactoring]
---

# 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

| Tool | Databases | Integration Method |
|------|-----------|-------------------|
| Flyway | Multi | CLI |
| Liquibase | Multi | CLI |
| Redgate SQL Compare | SQL Server | CLI |
| SchemaHero | Kubernetes | CLI |
| pgdiff | PostgreSQL | CLI |
| mysqldiff | MySQL | CLI |

## Output Schema

```json
{
  "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 attribution: a5c-ai
Original project: https://github.com/a5c-ai/babysitter
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

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: a5c-ai
Original project: https://github.com/a5c-ai/babysitter
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering, Data & Analytics, Product Management
Roles: Data Engineer, Database Administrator, Data Analyst, ML / AI Engineer, Product Manager
Specialties: Database
Tools: Flyway, Liquibase, Redgate Sql Compare, Schemahero, Pgdiff, Mysqldiff
Country applicability: Country not specified
Classification basis: Source category, role and specialization labels
Instruction SHA-256: 984aee45f20974b60da033a9d961d4de77ab076ad22eb9cb6874735b291ca10f
