Added diff to the tool
Some checks are pending
CI / Test (1.25) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Build (push) Waiting to run
CI / Test (1.23) (push) Waiting to run
CI / Test (1.24) (push) Waiting to run

This commit is contained in:
Hein
2025-12-18 13:38:32 +02:00
parent bed4f5d3bd
commit fcbceaf434
10 changed files with 1454 additions and 31 deletions

View File

@@ -221,4 +221,4 @@ func (w *Writer) constraintToDBML(c *models.Constraint, t *models.Table) string
}
return refLine + "\n"
}
}

View File

@@ -6,9 +6,10 @@ import (
"os"
"strings"
"github.com/google/uuid"
"git.warky.dev/wdevs/relspecgo/pkg/models"
"git.warky.dev/wdevs/relspecgo/pkg/writers"
"github.com/google/uuid"
)
// Writer implements the writers.Writer interface for DCTX format
@@ -43,9 +44,8 @@ func (w *Writer) WriteSchema(schema *models.Schema) error {
}
tableSlice := make([]*models.Table, 0, len(schema.Tables))
for _, t := range schema.Tables {
tableSlice = append(tableSlice, t)
}
tableSlice = append(tableSlice, schema.Tables...)
// Pass 1: Create fields and populate fieldGuidMap
for i, table := range tableSlice {
@@ -70,8 +70,8 @@ func (w *Writer) WriteSchema(schema *models.Schema) error {
isDuplicate := false
for _, existing := range allRelations {
if existing.Name == rel.Name &&
existing.FromTable == rel.FromTable &&
existing.ToTable == rel.ToTable {
existing.FromTable == rel.FromTable &&
existing.ToTable == rel.ToTable {
isDuplicate = true
break
}
@@ -310,8 +310,8 @@ func (w *Writer) mapRelation(rel *models.Relationship, schema *models.Schema) mo
// Create field mappings
// NOTE: DCTX has backwards naming - ForeignMapping contains PRIMARY table fields,
// and PrimaryMapping contains FOREIGN table fields
var foreignMappings []models.DCTXFieldMapping // Will contain primary table fields
var primaryMappings []models.DCTXFieldMapping // Will contain foreign table fields
var foreignMappings []models.DCTXFieldMapping // Will contain primary table fields
var primaryMappings []models.DCTXFieldMapping // Will contain foreign table fields
// Map foreign key columns (from foreign table) to PrimaryMapping
for _, colName := range fkColumns {

View File

@@ -68,9 +68,9 @@ func (w *Writer) GenerateDatabaseStatements(db *models.Database) ([]string, erro
statements := []string{}
// Add header comment
statements = append(statements, fmt.Sprintf("-- PostgreSQL Database Schema"))
statements = append(statements, "-- PostgreSQL Database Schema")
statements = append(statements, fmt.Sprintf("-- Database: %s", db.Name))
statements = append(statements, fmt.Sprintf("-- Generated by RelSpec"))
statements = append(statements, "-- Generated by RelSpec")
// Process each schema in the database
for _, schema := range db.Schemas {