Files
relspecgo/pkg/readers/drawdb
Hein 666eab7cec
Some checks failed
CI / Test (1.24) (push) Failing after -24m41s
CI / Test (1.25) (push) Failing after -24m25s
CI / Lint (push) Failing after -25m49s
CI / Build (push) Successful in -26m3s
Updated Readme files
2025-12-28 10:34:20 +02:00
..
2025-12-16 21:43:45 +02:00
2025-12-17 22:52:24 +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