Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lightning-fast .NET single-file script for database schema comparison and migration generation across PostgreSQL, MySQL, SQL Server, and SQLite

License

Tim-Maes/Schemer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎯 Schemer - Database Schema Diff Tool

A powerful, single-file C# application that compares database schemas across different environments and generates migration scripts. Supports PostgreSQL, MySQL, SQL Server, and SQLite.

✨ Features

  • Lightning-fast schema comparison across all major databases
  • Beautiful, colorful console output with rich formatting
  • Multiple output formats: Console, SQL, JSON, Markdown
  • Comprehensive change detection: tables, columns, indexes, constraints
  • Production-ready migration script generation
  • Zero-installation single-file deployment

🚀 Quick Start

1. Copy the Schemer.cs file to your local machine.

You can clone the repo and put the Schemer.cs file somewhere you like. Make sure you have the NET10 SDK or Runtime installed. (Currently still in preview)

2. Run a schema comparison:

You can run Schemer commands from the terminal.

Example using the test databases provided in this repository:

dotnet run schemer.cs
      --source "Data Source=schemer_source.db"
      --target "Data Source=schemer_target.db"
      --type sqlite

3. Example output

image

📋 Command Line Options

Option Description Required Default
--source Source database connection string -
--target Target database connection string -
--type Database type (postgres, mysql, sqlserver, sqlite) -
--output Output format (console, sql, json, markdown) console
--tables Comma-separated list of specific tables to compare all tables
--ignore Comma-separated list of tables/columns to ignore none
--migration-name Name for generated migration file auto-generated
--verbose Detailed output including debug information false

📊 Output Formats

Console (Default)

Beautiful, colorful console output with rich formatting showing:

  • Summary statistics
  • Missing, extra, and modified tables
  • Detailed column-level differences

SQL Migration Scripts

Generate production-ready migration scripts:

./schemer.cs ... --output sql --migration-name "update_user_schema"

JSON Reports

Machine-readable JSON format for integration with other tools:

./schemer.cs ... --output json

Markdown Documentation

Human-readable documentation format:

./schemer.cs ... --output markdown

🔧 Connection String Examples

PostgreSQL

postgres://username:password@hostname:5432/database
Host=hostname;Database=database;Username=username;Password=password

MySQL

mysql://username:password@hostname:3306/database
Server=hostname;Database=database;Uid=username;Pwd=password

SQL Server

Server=hostname;Database=database;Integrated Security=true
Server=hostname;Database=database;User Id=username;Password=password

SQLite

Data Source=database.db
Data Source=C:\path\to\database.sqlite

🛠️ Requirements

  • .NET 10.0 preview
  • Database-specific drivers (automatically included via NuGet packages)

📦 Dependencies

The following NuGet packages are automatically included:

  • Npgsql - PostgreSQL driver
  • MySqlConnector - MySQL driver
  • Microsoft.Data.SqlClient - SQL Server driver
  • Microsoft.Data.Sqlite - SQLite driver
  • Dapper - Micro ORM
  • Spectre.Console - Rich console UI
  • System.CommandLine - Command line parsing
  • Newtonsoft.Json - JSON serialization

🔒 Security Features

  • Connection string validation with basic SQL injection prevention
  • Credential masking in console output
  • Timeout handling for long-running operations
  • Retry logic with exponential backoff

🤝 Contributing

This is a single-file application designed for simplicity and portability. Contributions are welcome! Please ensure any changes maintain the single-file architecture.

About

Lightning-fast .NET single-file script for database schema comparison and migration generation across PostgreSQL, MySQL, SQL Server, and SQLite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages