5d60bc3b2c032412235eb1789c7fef5f2c6e7e6f
1. pkg/models/models.go:184 - Fixed typo in ForeignKeyConstraint constant from "foreign_Key" to "foreign_key" 2. pkg/readers/drawdb/reader.go:62-68 - Fixed ReadSchema() to properly detect schema name from tables instead of hardcoding "default" 3. pkg/writers/dbml/writer.go:128 - Changed primary key attribute from "primary key" to DBML standard "pk" 4. pkg/writers/dbml/writer.go:208-221 - Fixed foreign key reference format to use "table.column" syntax for single columns instead of "table.(column)" Test Results All reader and writer tests are now passing: Readers: - DBML: 74.4% coverage (2 tests skipped due to missing parser features for Ref statements) - DCTX: 77.6% coverage - DrawDB: 83.6% coverage - JSON: 82.1% coverage - YAML: 82.1% coverage Writers: - Bun: 68.5% coverage - DBML: 91.5% coverage - DCTX: 100.0% coverage - DrawDB: 83.8% coverage - GORM: 69.2% coverage - JSON: 82.4% coverage - YAML: 82.4% coverage
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 between various database specification formats, allowing you to:
- Inspect live databases and extract their structure
- Convert between different ORM models (GORM, Bun)
- Transform legacy schema definitions (Clarion DCTX, XML, JSON)
- Generate standardized specification files (JSON, YAML)
Features
Input Formats
- XML - Generic XML schema definitions
- JSON - JSON-based schema specifications
- Clarion DCTX - Clarion database dictionary format
- Database Inspection - Direct database introspection
- GORM Models - Read existing GORM Go structs
- Bun Models - Read existing Bun Go structs
Output Formats
- GORM Models - Generate GORM-compatible Go structs
- Bun Models - Generate Bun-compatible Go structs
- JSON - Standard JSON schema output
- YAML - Human-readable YAML format
Installation
go get github.com/wdevs/relspecgo
Usage
# Inspect database and generate GORM models
relspec --input db --conn "postgres://..." --output gorm --out-file models.go
# Convert GORM models to Bun
relspec --input gorm --in-file existing.go --output bun --out-file bun_models.go
# Export database schema to JSON
relspec --input db --conn "mysql://..." --output json --out-file schema.json
# Convert Clarion DCTX to YAML
relspec --input dctx --in-file legacy.dctx --output yaml --out-file schema.yaml
Project Structure
relspecgo/
├── cmd/ # CLI application
├── pkg/
│ ├── readers/ # Input format readers
│ ├── writers/ # Output format writers
│ ├── models/ # Internal data models
│ └── transform/ # Transformation logic
├── examples/ # Usage examples
└── tests/ # Test files
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 wdevs
Contributing
Contributions welcome. Please open an issue or submit a pull request.
Description
