Hein 97a57f5dc8
Some checks failed
CI / Test (1.24) (push) Successful in -25m44s
CI / Test (1.25) (push) Successful in -25m40s
CI / Build (push) Successful in -25m53s
CI / Lint (push) Successful in -25m45s
Integration Tests / Integration Tests (push) Failing after -26m2s
feature: Inspector Gadget
2025-12-31 01:40:08 +02:00
2025-12-17 20:44:02 +02:00
2025-12-28 20:36:36 +02:00
2025-12-18 21:39:37 +02:00
2025-12-31 01:40:08 +02:00
2025-12-31 00:44:14 +02:00
2025-12-18 13:38:32 +02:00
2025-12-31 01:40:08 +02:00
2025-12-28 15:37:21 +02:00
2025-12-19 22:27:20 +02:00
2025-12-16 13:12:43 +02:00
2025-12-18 14:37:34 +02:00
2025-12-16 13:12:43 +02:00
2025-12-28 10:15:30 +02:00
2025-12-18 14:35:05 +02:00
2025-12-16 13:12:43 +02:00
2025-12-28 15:37:21 +02:00
2025-12-19 22:27:20 +02:00
2025-12-19 22:27:20 +02:00
2025-12-16 08:38:49 +00:00
2025-12-28 15:37:21 +02:00
2025-12-31 01:40:08 +02:00
2025-12-31 01:40:08 +02:00

RelSpec

Database Relations Specification Tool for Go

RelSpec is a comprehensive database relations management tool that reads, transforms, and writes database table specifications across multiple formats and ORMs.

Overview

RelSpec provides bidirectional conversion, comparison, and validation of database specification formats, allowing you to:

  • Inspect live databases and extract their structure
  • Validate schemas against configurable rules and naming conventions
  • Convert between different ORM models (GORM, Bun, etc.)
  • Transform legacy schema definitions (Clarion DCTX, XML, JSON, etc.)
  • Generate standardized specification files (JSON, YAML, etc.)
  • Compare database schemas and track changes

1.00

Features

Readers (Input Formats)

RelSpec can read database schemas from multiple sources:

ORM Models

  • GORM - Go GORM model definitions
  • Bun - Go Bun model definitions
  • Drizzle - TypeScript Drizzle ORM schemas
  • Prisma - Prisma schema language
  • TypeORM - TypeScript TypeORM entities

Database Inspection

  • PostgreSQL - Direct PostgreSQL database introspection

Schema Formats

  • DBML - Database Markup Language (dbdiagram.io)
  • DCTX - Clarion database dictionary format
  • DrawDB - DrawDB JSON format
  • GraphQL - GraphQL Schema Definition Language (SDL)
  • JSON - RelSpec canonical JSON format
  • YAML - RelSpec canonical YAML format

Writers (Output Formats)

RelSpec can write database schemas to multiple formats:

ORM Models

  • GORM - Generate GORM-compatible Go structs
  • Bun - Generate Bun-compatible Go structs
  • Drizzle - Generate Drizzle ORM TypeScript schemas
  • Prisma - Generate Prisma schema files
  • TypeORM - Generate TypeORM TypeScript entities

Database DDL

  • PostgreSQL - PostgreSQL DDL (CREATE TABLE, etc.)

Schema Formats

  • DBML - Database Markup Language
  • DCTX - Clarion database dictionary format
  • DrawDB - DrawDB JSON format
  • GraphQL - GraphQL Schema Definition Language (SDL)
  • JSON - RelSpec canonical JSON format
  • YAML - RelSpec canonical YAML format

Inspector (Schema Validation)

RelSpec includes a powerful schema validation and linting tool:

  • Inspector - Validate database schemas against configurable rules
    • Enforce naming conventions (snake_case, camelCase, custom patterns)
    • Check primary key and foreign key standards
    • Detect missing indexes on foreign keys
    • Prevent use of SQL reserved keywords
    • Ensure schema integrity (missing PKs, orphaned FKs, circular dependencies)
    • Support for custom validation rules
    • Multiple output formats (Markdown with colors, JSON)
    • CI/CD integration ready

Use of AI

Rules and use of AI

Installation

go get github.com/wdevs/relspecgo

go install -v git.warky.dev/wdevs/relspecgo/cmd/relspec@latest

Usage

Schema Conversion

# Convert PostgreSQL database to GORM models
relspec convert --from pgsql --from-conn "postgres://user:pass@localhost/mydb" \
                --to gorm --to-path models/ --package models

# Convert GORM models to Bun
relspec convert --from gorm --from-path models.go \
                --to bun --to-path bun_models.go --package models

# Export database schema to JSON
relspec convert --from pgsql --from-conn "postgres://..." \
                --to json --to-path schema.json

# Convert DBML to PostgreSQL SQL
relspec convert --from dbml --from-path schema.dbml \
                --to pgsql --to-path schema.sql

Schema Validation

# Validate a PostgreSQL database with default rules
relspec inspect --from pgsql --from-conn "postgres://user:pass@localhost/mydb"

# Validate DBML file with custom rules
relspec inspect --from dbml --from-path schema.dbml --rules .relspec-rules.yaml

# Generate JSON validation report
relspec inspect --from json --from-path db.json \
                --output-format json --output report.json

# Validate specific schema only
relspec inspect --from pgsql --from-conn "..." --schema public

Schema Comparison

# Compare two database schemas
relspec diff --from pgsql --from-conn "postgres://localhost/db1" \
             --to pgsql --to-conn "postgres://localhost/db2"

Project Structure

relspecgo/
├── cmd/
│   └── relspec/      # CLI application (convert, inspect, diff, scripts)
├── pkg/
│   ├── readers/      # Input format readers (DBML, GORM, PostgreSQL, etc.)
│   ├── writers/      # Output format writers (GORM, Bun, SQL, etc.)
│   ├── inspector/    # Schema validation and linting
│   ├── diff/         # Schema comparison
│   ├── models/       # Internal data models
│   ├── transform/    # Transformation logic
│   └── pgsql/        # PostgreSQL utilities (keywords, data types)
├── examples/         # Usage examples
└── tests/            # Test files

Todo

Todo List of Features

Development

Prerequisites

  • Go 1.21 or higher
  • Access to test databases (optional)

Building

go build -o relspec ./cmd/relspec

Testing

go test ./...

License

Apache License 2.0 - See LICENSE for details.

Copyright 2025 Warky Devs

Contributing

Contributions welcome. Please open an issue or submit a pull request.

Description
Resolve Spec Go
Readme Apache-2.0 7.4 MiB
v1.0.12 Latest
2026-01-10 16:28:51 +00:00
Languages
Go 96.5%
TypeScript 2.1%
Shell 0.8%
Makefile 0.6%