SkillAgentSearch skills...

schemaforge

Bidirectional ORM schema conversion across 11 formats (SQLAlchemy, Django, Prisma, etc.)

Install / Use

claude mcp add Coding-Dev-Tools -- npx -y github:Coding-Dev-Tools/schemaforge

If the server publishes to npm under a different name, use that package instead — check the repo README.

About this skill
🔌

MCP Server

Model Context Protocol server

Quality Score

69/100

Supported Platforms

Claude Code
Claude Desktop

SchemaForge

Bidirectional ORM schema converter — convert between SQL DDL, Prisma, Drizzle, TypeORM, Django, SQLAlchemy, Alembic migrations, JSON Schema, GraphQL SDL, EF Core (C#), and Scala case classes. 11 formats, 100 conversion directions.

GitHub stars Python License CI Tests VS Code Open Source Alternative

Why SchemaForge?

Convert any schema to any format, verify equivalence with the diff command, generate Alembic migrations, produce JSON Schema definitions, create GraphQL SDL types, convert Entity Framework (C#) entities, generate Scala case classes, and batch-process entire directories. Whether you're migrating from Prisma to Drizzle, sharing a schema with a Django backend, exposing your data model as GraphQL, translating C# entities to Scala, or working with the SchemaForge VS Code extension for live preview — SchemaForge handles it.

Quick Start

# Install (package publishing pending — install from source)
pip install git+https://github.com/Coding-Dev-Tools/schemaforge.git

# Convert Prisma → Drizzle
schemaforge convert --from prisma --to drizzle --input schema.prisma

# Generate GraphQL from SQL
schemaforge convert --from sql --to graphql --input schema.sql --output schema.graphql

# Generate JSON Schema from Prisma
schemaforge convert --from prisma --to json_schema --input schema.prisma --output schema.json

# Generate Alembic migration from SQL
schemaforge convert --from sql --to alembic --input schema.sql --output migrations/initial.py

# Apply custom type mappings
schemaforge convert --from sql --to prisma --input schema.sql --type-map my-types.yaml

# Diff two schemas
schemaforge diff schema-v1.prisma schema-v2.prisma

# Check all schemas in a directory are consistent
schemaforge check --dir ./schemas/

Installation

# Install from source (recommended — PyPI publishing pending)
pip install git+https://github.com/Coding-Dev-Tools/schemaforge.git

Requires Python 3.10+.

Commands

schemaforge convert

Convert a schema from one format to another. Every format converts to and from every other format, except Alembic which is generator-only (a target, not a source) — 100 direction pairs.

# Format-specific examples
schemaforge convert --from sql --to prisma --input schema.sql
schemaforge convert --from prisma --to drizzle --input schema.prisma
schemaforge convert --from drizzle --to sql --input schema.drizzle.ts
schemaforge convert --from typeorm --to django --input entities/
schemaforge convert --from django --to sqlalchemy --input models.py
schemaforge convert --from sqlalchemy --to prisma --input models.py

# Alembic migration generation
schemaforge convert --from sql --to alembic --input schema.sql --output migrations/initial.py
schemaforge convert --from prisma --to alembic --input schema.prisma --output migrations/

# JSON Schema
schemaforge convert --from sql --to json_schema --input schema.sql --output schema.json
schemaforge convert --from json_schema --to prisma --input schema.json

# GraphQL SDL
schemaforge convert --from sql --to graphql --input schema.sql --output schema.graphql
schemaforge convert --from graphql --to prisma --input schema.graphql

# Custom type mapping
schemaforge convert --from sql --to prisma --input schema.sql --type-map my-types.yaml

# Dir mode (check all files are consistent)
schemaforge check --dir ./schemas/ --canonical prisma

schemaforge diff

Compare two schema files in the same format and see line-level differences.

schemaforge diff schema-v1.prisma schema-v2.prisma
schemaforge diff schema.sql schema-updated.sql --format sql
schemaforge diff fixtures/sample.sql fixtures/sample.prisma --format prisma

Detects added, removed, and modified tables, columns, indexes, and constraints.

Supported Formats

| Format | Import | Export | Roundtrip | |--------|:------:|:------:|:---------:| | SQL DDL | ✓ | ✓ | ✓ | | Prisma schema | ✓ | ✓ | ✓ | | Drizzle schema | ✓ | ✓ | ✓ | | TypeORM entities | ✓ | ✓ | ✓ | | Django models | ✓ | ✓ | ✓ | | SQLAlchemy models | ✓ | ✓ | ✓ | | Alembic migrations | — | ✓ | — | | JSON Schema | ✓ | ✓ | ✓ | | GraphQL SDL | ✓ | ✓ | ✓ | | EF Core (C#) | ✓ | ✓ | ✓ | | Scala case class | ✓ | ✓ | ✓ |

Alembic is generator-only: you can create migration scripts from any format, but parsing existing migrations back to IR is not yet supported.

Limitations

  • Foreign keys & relationships — the shared IR does not yet model foreign-key constraints or ORM relations, so FOREIGN KEY / REFERENCES clauses, Prisma/TypeORM relation fields, and Django ForeignKey fields are dropped during conversion rather than roundtripped. Tables, columns, types, defaults, indexes, unique constraints, and enums are preserved. FK support is on the roadmap.
  • Alembic is generator-only (see above) — you can generate migrations from any format but not parse them back.

Format Identifiers for --from / --to

| CLI identifier | Format | |----------------|--------| | sql | SQL DDL | | prisma | Prisma schema | | drizzle | Drizzle ORM schema | | typeorm | TypeORM entities | | django | Django models | | sqlalchemy | SQLAlchemy declarative models | | alembic | Alembic migration scripts | | json_schema | JSON Schema (draft 2020-12) | | graphql | GraphQL SDL | | ef | Entity Framework Core (C#) | | scala | Scala case classes (Doobie/Quill/Slick) |

How It Works

SchemaForge uses a shared Internal Representation (IR) — all formats convert to and from this common schema definition. This architecture guarantees:

  • High-fidelity roundtripping: sql → prisma → sql reproduces tables, columns, types, defaults, indexes, unique constraints, and enums. Foreign-key/relationship constraints are not yet modeled in the IR and are dropped (see Limitations).
  • Bidirectional conversion: every format can convert to every other format, except Alembic, which is generator-only (a target, not a source)
  • Extensibility: adding a new format requires only a parser and a generator — no pairwise converters
|    SQL DDL ───┐
|    Prisma ────┤
|    Drizzle ───┤
|    TypeORM ───┤
|    Django ────┤
| SQLAlchemy ───┤
|   Alembic ────┤
| JSON Schema ──┤
|   GraphQL ────┤
|  EF Core ─────┤
|    Scala ─────┤

Each parser reads format-specific syntax and builds a schema IR. Each generator takes the same IR and produces format-native output. The fn: prefix convention preserves SQL function defaults (CURRENT_TIMESTAMP, NOW(), gen_random_uuid()) across format boundaries.

Custom Type Mappings (v1.1.0+)

Override default type mappings with YAML or JSON configuration files.

# type-overrides.yaml
overrides:
  prisma:
    STRING: "String @db.VarChar({length})"
    UUID: "String @db.Uuid"
  sql:
    STRING: "TEXT"
    DATETIME: "TIMESTAMP WITH TIME ZONE"

Template variables available: {length}, {precision}, {scale}, {values}.

# Apply overrides during conversion
schemaforge convert --from sql --to prisma --input schema.sql --type-map type-overrides.yaml

Type Mapping

SchemaForge maps types intelligently between ORM systems. The core ColumnType enum represents all supported data types, and each format maps them to their native equivalents.

| ColumnType | SQL DDL | Prisma | Drizzle | TypeORM | Django | SQLAlchemy | Alembic | JSON Schema | GraphQL | |------------|---------|--------|---------|---------|--------|------------|---------|-------------|---------| | STRING | VARCHAR(n) / TEXT | String @db.VarChar(n) | varchar(n) | varchar | CharField(max_length=n) | String(n) | sa.String(n) | type: string | String | | INTEGER | INTEGER | Int | integer | integer | IntegerField | Integer | sa.Integer | type: integer | Int | | FLOAT | FLOAT | Float | real | float | FloatField | Float | sa.Float | type: number | Float | | BOOLEAN | BOOLEAN | Boolean | boolean | boolean | BooleanField | Boolean | sa.Boolean | type: boolean | Boolean | | DATETIME | TIMESTAMP | DateTime | timestamp | timestamp | DateTimeField | DateTime | sa.DateTime | format: date-time | DateTime | | DATE | DATE | DateTime | date | date | DateField | Date | sa.Date | format: date | Date | | TIME | TIME | DateTime | time | time | TimeField | Time | sa.Time | format: time | Time | | TEXT | TEXT | String | text | text | TextField | Text | sa.Text | type: string | String | | BLOB | BLOB | Bytes | blob | blob | BinaryField | LargeBinary | sa.LargeBinary | format: binary | String | | JSON | JSON | Json | json | json | JSONField | JSON | sa.JSON | type: object | JSON | | UUID | UUID | String | uuid | uuid | UUIDField | Uuid | sa.Uuid | format: uuid | ID | | ENUM | ENUM('a','b') | (via enum) | pgEnum | enum | CharField | Enum | sa.Enum | (enum) | enum | | DECIMAL | DECIMAL(p,s) | Decimal | numeric(p,s) | decimal(p,s) | DecimalField | Numeric(p,s) | sa.Numeric(p,s) | type: number | Float | | CUSTOM | (passthrough) | (passthrough) | (passthrough) | (passthrough) | (passthrough) | (passthrough) | (passthrough) | (passthrough) | (passthrough) |

Function defaults (CURRENT_TIMESTAMP, NOW(), gen_random_uuid(), etc.) are preserved across conversions using a fn: prefix convention.

Demo Fixtures

Try SchemaForge immediately with our example blog schema. The fixtures/ directory contains an equivalent schema (users, posts, categories with enums and various data types) in all 11 formats:

# List all fixtures
ls fixtures/

# Convert SQL → Prisma
schemaforge convert --from sql --to prisma --input fixtures/sample.sql

# Convert Prisma → Django
schemaforge convert --from prisma --to django --input fixtures/sample.prisma

# Convert SQL → GraphQL
schemaforge convert --from sql --to graphql --input fixtures/sample.sql

# Convert SQL → JSON Schema
schemaforge convert --from sql --to json_schema --input fixtures/sample.sql

# Convert Prisma → Alembic migration
schemaforge convert --from prisma --to alembic --input fixtures/sample.prisma --output migrations/

# Custom type mapping demo
schemaforge convert --from sql --to prisma --input fixtures/sample.sql \
  --type-map fixtures/sample-type-overrides.yaml

# Batch convert all fixtures from SQL
schemaforge check --dir fixtures/

# Diff two format outputs
schemaforge diff fixtures/sample.sql fixtures/sample.prisma --format prisma

Each fixture demonstrates the same blog schema so you can compare ORM syntax side-by-side and verify roundtrip consistency.

Features

  • Bidirectional conversion — every format converts to and from every other format (Alembic is generator-only: a target, not a source)
  • High-fidelity roundtrippingsql → prisma → sql reproduces tables, columns, types, defaults, indexes, and enums (foreign keys are not yet preserved — see Limitations)
  • Custom type mappings — YAML/JSON config files to override any type mapping with template variables
  • VS Code extension — live preview, schema diff, and one-click conversion from VS Code
  • **Alembic migration generation

Truncated for display — read the full file on GitHub.

Related Skills

View on GitHub
GitHub Stars3
CategoryData
Updated7d ago
Forks1

Languages

Python

Security Score

87/100

Audited on Aug 25, 2026

2 low