fix: readers and linting issues
Some checks failed
CI / Test (1.24) (push) Failing after -24m50s
CI / Test (1.25) (push) Failing after -24m42s
CI / Build (push) Successful in -25m49s
CI / Lint (push) Successful in -25m36s

This commit is contained in:
2025-12-19 22:28:24 +02:00
parent d9225a7310
commit aad5db5175
16 changed files with 1237 additions and 80 deletions

View File

@@ -2,14 +2,15 @@ package diff
import (
"reflect"
"git.warky.dev/wdevs/relspecgo/pkg/models"
)
// CompareDatabases compares two database models and returns the differences
func CompareDatabases(source, target *models.Database) *DiffResult {
result := &DiffResult{
Source: source.Name,
Target: target.Name,
Source: source.Name,
Target: target.Name,
Schemas: compareSchemas(source.Schemas, target.Schemas),
}
return result

View File

@@ -4,8 +4,8 @@ import "git.warky.dev/wdevs/relspecgo/pkg/models"
// DiffResult represents the complete difference analysis between two databases
type DiffResult struct {
Source string `json:"source"`
Target string `json:"target"`
Source string `json:"source"`
Target string `json:"target"`
Schemas *SchemaDiff `json:"schemas"`
}
@@ -18,17 +18,17 @@ type SchemaDiff struct {
// SchemaChange represents changes within a schema
type SchemaChange struct {
Name string `json:"name"`
Tables *TableDiff `json:"tables,omitempty"`
Views *ViewDiff `json:"views,omitempty"`
Sequences *SequenceDiff `json:"sequences,omitempty"`
Name string `json:"name"`
Tables *TableDiff `json:"tables,omitempty"`
Views *ViewDiff `json:"views,omitempty"`
Sequences *SequenceDiff `json:"sequences,omitempty"`
}
// TableDiff represents differences in tables
type TableDiff struct {
Missing []*models.Table `json:"missing"` // Tables in source but not in target
Extra []*models.Table `json:"extra"` // Tables in target but not in source
Modified []*TableChange `json:"modified"` // Tables that exist in both but differ
Missing []*models.Table `json:"missing"` // Tables in source but not in target
Extra []*models.Table `json:"extra"` // Tables in target but not in source
Modified []*TableChange `json:"modified"` // Tables that exist in both but differ
}
// TableChange represents changes within a table
@@ -50,16 +50,16 @@ type ColumnDiff struct {
// ColumnChange represents a modified column
type ColumnChange struct {
Name string `json:"name"`
Source *models.Column `json:"source"`
Target *models.Column `json:"target"`
Changes map[string]any `json:"changes"` // Map of field name to what changed
Name string `json:"name"`
Source *models.Column `json:"source"`
Target *models.Column `json:"target"`
Changes map[string]any `json:"changes"` // Map of field name to what changed
}
// IndexDiff represents differences in indexes
type IndexDiff struct {
Missing []*models.Index `json:"missing"` // Indexes in source but not in target
Extra []*models.Index `json:"extra"` // Indexes in target but not in source
Missing []*models.Index `json:"missing"` // Indexes in source but not in target
Extra []*models.Index `json:"extra"` // Indexes in target but not in source
Modified []*IndexChange `json:"modified"` // Indexes that exist in both but differ
}
@@ -103,8 +103,8 @@ type RelationshipChange struct {
// ViewDiff represents differences in views
type ViewDiff struct {
Missing []*models.View `json:"missing"` // Views in source but not in target
Extra []*models.View `json:"extra"` // Views in target but not in source
Missing []*models.View `json:"missing"` // Views in source but not in target
Extra []*models.View `json:"extra"` // Views in target but not in source
Modified []*ViewChange `json:"modified"` // Views that exist in both but differ
}
@@ -133,14 +133,14 @@ type SequenceChange struct {
// Summary provides counts for quick overview
type Summary struct {
Schemas SchemaSummary `json:"schemas"`
Tables TableSummary `json:"tables"`
Columns ColumnSummary `json:"columns"`
Indexes IndexSummary `json:"indexes"`
Constraints ConstraintSummary `json:"constraints"`
Schemas SchemaSummary `json:"schemas"`
Tables TableSummary `json:"tables"`
Columns ColumnSummary `json:"columns"`
Indexes IndexSummary `json:"indexes"`
Constraints ConstraintSummary `json:"constraints"`
Relationships RelationshipSummary `json:"relationships"`
Views ViewSummary `json:"views"`
Sequences SequenceSummary `json:"sequences"`
Views ViewSummary `json:"views"`
Sequences SequenceSummary `json:"sequences"`
}
type SchemaSummary struct {