Added diff to the tool
This commit is contained in:
@@ -221,4 +221,4 @@ func (w *Writer) constraintToDBML(c *models.Constraint, t *models.Table) string
|
||||
}
|
||||
|
||||
return refLine + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user