TopRank Skills

Home / Claw Skills / Autres / database-schema-differ
Official OpenClaw rules 15%

database-schema-differ

Compare database schemas across environments, generate migration scripts, and track schema evolution.

Stars

0

Installs

0

Status

ACTIVE

Visibility

PUBLIC

安装方式

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 database-schema-differ 技能。 若已安装,则直接安装 database-schema-differ 技能。

Overview

Skill Key
derick001/database-schema-differ
Author
skill-factory
Source Repo
openclaw/skills
Version
1.0.0
Source Path
skills/derick001/database-schema-differ
Latest Commit SHA
48eeb585c9f8ba9dddde5ecef34871e6bc586058

Extracted Content

SKILL.md excerpt

# Database Schema Differ

## What This Does

A CLI tool to compare database schemas across different environments (development, staging, production), generate migration scripts, and track schema evolution over time. Support for PostgreSQL, MySQL, SQLite, and other databases via SQLAlchemy.

Key features:
- **Schema comparison**: Compare schemas between databases, branches, or points in time
- **Migration generation**: Automatically generate SQL migration scripts (up/down) for schema changes
- **Schema snapshots**: Capture and store schema snapshots for historical comparison
- **Drift detection**: Identify schema drift between environments (dev vs prod, etc.)
- **Multiple database support**: PostgreSQL, MySQL, SQLite, SQL Server, Oracle via SQLAlchemy
- **Export formats**: Generate SQL, JSON, or visual diff outputs
- **Integration ready**: Works with Alembic, Django migrations, or standalone
- **Change tracking**: Track schema evolution over time with versioning
- **CI/CD friendly**: Output machine-readable formats for automation pipelines

## When To Use

- You need to compare database schemas between development and production
- You want to generate migration scripts for schema changes
- You're managing multiple database environments and need to ensure consistency
- You need to detect schema drift in production databases
- You're refactoring databases and need to track changes
- You want to automate schema validation in CI/CD pipelines
- You need to document schema changes for compliance or team coordination
- You're onboarding new team members and need to understand schema evolution
- You want to visualize schema differences between branches or versions

## Usage

Basic commands:

```bash
# Compare two database connections
python3 scripts/main.py compare postgresql://user:pass@host1/db postgresql://user:pass@host2/db

# Generate migration script from schema differences
python3 scripts/main.py diff dev_db.sql prod_db.sql --output migration.sql

# Create schema snap...

README excerpt

# Database Schema Differ

Compare database schemas across environments, generate migration scripts, and track schema evolution.

## Features

- Compare schemas between databases, SQL files, or schema snapshots
- Generate SQL migration scripts (up/down) for schema changes
- Detect schema drift between environments
- Support for PostgreSQL, MySQL, SQLite, and other databases via SQLAlchemy
- Multiple output formats (SQL, JSON, HTML visual diff)
- Schema snapshotting for historical comparison

## Quick Start

```bash
# Compare two databases
python3 scripts/main.py compare postgresql://user:pass@host1/db postgresql://user:pass@host2/db

# Generate migration from schema differences
python3 scripts/main.py diff schema_v1.sql schema_v2.sql --output migration.sql

# Create schema snapshot
python3 scripts/main.py snapshot postgresql://user:pass@host/db --save snapshot.json

# Check for schema drift in CI
python3 scripts/main.py check-drift --expected expected.json --actual actual.json --fail-on-drift
```

## Installation

This skill requires Python 3.x and SQLAlchemy:

```bash
pip3 install sqlalchemy alembic psycopg2-binary pymysql
```

Database-specific drivers:
- PostgreSQL: `psycopg2-binary`
- MySQL: `pymysql`
- SQLite: Built into Python
- SQL Server: `pyodbc`
- Oracle: `cx_oracle`

## Usage Examples

### Compare development and production
```bash
python3 scripts/main.py compare \
  postgresql://dev:pass@localhost/dev_db \
  postgresql://prod:pass@prod-host/prod_db \
  --output diff.json
```

### Generate visual HTML diff
```bash
python3 scripts/main.py visual-diff schema1.sql schema2.sql --html diff.html
```

### Track schema changes over time
```bash
python3 scripts/main.py history postgresql://user:pass@host/db --days 30 --format timeline
```

## Output Formats

- **Human-readable**: Color-coded terminal output
- **JSON**: Machine-readable for automation
- **SQL**: Ready-to-execute migration scripts
- **HTML**: Interactive visual diff in browser

## Limitations

- Requ...

Related Claw Skills