Files
relspecgo/tests/assets/drawdb/complex.json
Hein 5d60bc3b2c
Some checks are pending
CI / Test (1.23) (push) Waiting to run
CI / Test (1.24) (push) Waiting to run
CI / Test (1.25) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Build (push) Waiting to run
Bugs Fixed
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
2025-12-16 21:43:45 +02:00

180 lines
3.5 KiB
JSON

{
"tables": [
{
"id": 0,
"name": "users",
"schema": "public",
"comment": "User accounts",
"color": "#3b82f6",
"x": 100,
"y": 100,
"fields": [
{
"id": 0,
"name": "id",
"type": "bigint",
"primary": true,
"notNull": true,
"increment": true
},
{
"id": 1,
"name": "email",
"type": "varchar(255)",
"unique": true,
"notNull": true
},
{
"id": 2,
"name": "username",
"type": "varchar(50)",
"notNull": true
},
{
"id": 3,
"name": "created_at",
"type": "timestamp",
"notNull": true,
"default": "CURRENT_TIMESTAMP"
}
],
"indexes": [
{
"id": 0,
"name": "idx_users_email",
"unique": true,
"fields": [1]
}
]
},
{
"id": 1,
"name": "posts",
"schema": "public",
"comment": "Blog posts",
"color": "#10b981",
"x": 400,
"y": 100,
"fields": [
{
"id": 0,
"name": "id",
"type": "bigint",
"primary": true,
"notNull": true,
"increment": true
},
{
"id": 1,
"name": "user_id",
"type": "bigint",
"notNull": true
},
{
"id": 2,
"name": "title",
"type": "varchar(200)",
"notNull": true
},
{
"id": 3,
"name": "content",
"type": "text"
},
{
"id": 4,
"name": "published",
"type": "boolean",
"default": "false"
}
],
"indexes": [
{
"id": 0,
"name": "idx_posts_user_id",
"unique": false,
"fields": [1]
}
]
},
{
"id": 2,
"name": "comments",
"schema": "public",
"color": "#f59e0b",
"x": 700,
"y": 100,
"fields": [
{
"id": 0,
"name": "id",
"type": "bigint",
"primary": true,
"notNull": true,
"increment": true
},
{
"id": 1,
"name": "post_id",
"type": "bigint",
"notNull": true
},
{
"id": 2,
"name": "user_id",
"type": "bigint",
"notNull": true
},
{
"id": 3,
"name": "content",
"type": "text",
"notNull": true
}
]
}
],
"relationships": [
{
"id": 0,
"name": "fk_posts_user",
"startTableId": 1,
"endTableId": 0,
"startFieldId": 1,
"endFieldId": 0,
"cardinality": "Many to one",
"updateConstraint": "CASCADE",
"deleteConstraint": "CASCADE"
},
{
"id": 1,
"name": "fk_comments_post",
"startTableId": 2,
"endTableId": 1,
"startFieldId": 1,
"endFieldId": 0,
"cardinality": "Many to one",
"deleteConstraint": "CASCADE"
},
{
"id": 2,
"name": "fk_comments_user",
"startTableId": 2,
"endTableId": 0,
"startFieldId": 2,
"endFieldId": 0,
"cardinality": "Many to one",
"deleteConstraint": "SET NULL"
}
],
"notes": [
{
"id": 0,
"content": "Database: test_db",
"color": "#fbbf24",
"x": 100,
"y": 400
}
]
}