MCPcopy Index your code
hub / github.com/bytebase/bytebase / compareTableDetails

Function compareTableDetails

backend/plugin/schema/differ.go:534–597  ·  view source on GitHub ↗

compareTableDetails compares the details of two tables.

(engine storepb.Engine, schemaName, tableName string, oldTable, newTable *model.TableMetadata)

Source from the content-addressed store, hash-verified

532
533// compareTableDetails compares the details of two tables.
534func compareTableDetails(engine storepb.Engine, schemaName, tableName string, oldTable, newTable *model.TableMetadata) *TableDiff {
535 tableDiff := &TableDiff{
536 Action: MetadataDiffActionAlter,
537 SchemaName: schemaName,
538 TableName: tableName,
539 OldTable: oldTable.GetProto(),
540 NewTable: newTable.GetProto(),
541 }
542
543 hasChanges := false
544
545 // Compare columns
546 columnChanges := compareColumns(engine, oldTable, newTable)
547 if len(columnChanges) > 0 {
548 tableDiff.ColumnChanges = columnChanges
549 hasChanges = true
550 }
551
552 // Compare indexes
553 indexChanges := compareIndexes(engine, oldTable, newTable)
554 if len(indexChanges) > 0 {
555 tableDiff.IndexChanges = indexChanges
556 hasChanges = true
557 }
558
559 // Compare foreign keys
560 fkChanges := compareForeignKeys(oldTable.GetProto().ForeignKeys, newTable.GetProto().ForeignKeys)
561 if len(fkChanges) > 0 {
562 tableDiff.ForeignKeyChanges = fkChanges
563 hasChanges = true
564 }
565
566 // Compare check constraints
567 checkChanges := compareCheckConstraints(engine, oldTable.GetProto().CheckConstraints, newTable.GetProto().CheckConstraints)
568 if len(checkChanges) > 0 {
569 tableDiff.CheckConstraintChanges = checkChanges
570 hasChanges = true
571 }
572
573 // Compare partitions
574 partitionChanges := comparePartitions(engine, oldTable.GetProto().Partitions, newTable.GetProto().Partitions)
575 if len(partitionChanges) > 0 {
576 tableDiff.PartitionChanges = partitionChanges
577 hasChanges = true
578 }
579
580 // Compare triggers
581 triggerChanges := compareTriggers(oldTable.GetProto().Triggers, newTable.GetProto().Triggers)
582 if len(triggerChanges) > 0 {
583 tableDiff.TriggerChanges = triggerChanges
584 hasChanges = true
585 }
586
587 // Compare table comments
588 if oldTable.GetProto().Comment != newTable.GetProto().Comment {
589 hasChanges = true
590 }
591

Callers 1

compareSchemaObjectsFunction · 0.85

Calls 7

compareTriggersFunction · 0.85
compareColumnsFunction · 0.70
compareIndexesFunction · 0.70
compareForeignKeysFunction · 0.70
compareCheckConstraintsFunction · 0.70
comparePartitionsFunction · 0.70
GetProtoMethod · 0.45

Tested by

no test coverage detected