Files
Hein 5d3c86119e
Some checks failed
CI / Test (1.24) (push) Successful in -27m28s
CI / Test (1.25) (push) Successful in -27m30s
CI / Build (push) Failing after -28m36s
Integration Tests / Integration Tests (push) Failing after -28m8s
CI / Lint (push) Successful in -27m54s
feat(domains): add domain support for DrawDB integration
- Introduce Domain and DomainTable models for logical grouping of tables.
- Implement export and import functionality for domains in DrawDB format.
- Update template execution modes to include domain processing.
- Enhance documentation for domain features and usage.
2026-01-04 15:49:47 +02:00
..
2025-12-16 21:43:45 +02:00
2025-12-28 10:34:20 +02:00

DrawDB Reader

Reads DrawDB schema files and extracts database schema information.

Overview

The DrawDB Reader parses JSON files exported from DrawDB (a free online database design tool) and converts them into RelSpec's internal database model representation.

Features

  • Parses DrawDB JSON format
  • Extracts tables, fields, and relationships
  • Supports DrawDB-specific metadata
  • Preserves visual layout information

Usage

Basic Example

package main

import (
    "fmt"
    "git.warky.dev/wdevs/relspecgo/pkg/readers"
    "git.warky.dev/wdevs/relspecgo/pkg/readers/drawdb"
)

func main() {
    options := &readers.ReaderOptions{
        FilePath: "/path/to/diagram.json",
    }

    reader := drawdb.NewReader(options)
    db, err := reader.ReadDatabase()
    if err != nil {
        panic(err)
    }

    fmt.Printf("Found %d schemas\n", len(db.Schemas))
}

CLI Example

# Read DrawDB export and convert to JSON schema
relspec --input drawdb --in-file diagram.json --output json --out-file schema.json

# Convert DrawDB design to GORM models
relspec --input drawdb --in-file design.json --output gorm --out-file models.go

Example DrawDB Export

DrawDB exports database designs as JSON files containing:

{
  "tables": [
    {
      "id": "1",
      "name": "users",
      "fields": [
        {
          "name": "id",
          "type": "BIGINT",
          "primary": true,
          "autoIncrement": true
        },
        {
          "name": "username",
          "type": "VARCHAR",
          "size": 50,
          "notNull": true,
          "unique": true
        }
      ]
    }
  ],
  "relationships": [
    {
      "source": "posts",
      "target": "users",
      "type": "many-to-one"
    }
  ]
}

Notes

  • DrawDB is a free online database designer at drawdb.vercel.app
  • Export format preserves visual design metadata
  • Useful for converting visual designs to code
  • Schema defaults to public