compareEvents compares events between old and new schemas.
(diff *MetadataDiff, _ string, oldSchema, newSchema *model.SchemaMetadata)
| 2095 | |
| 2096 | // compareEvents compares events between old and new schemas. |
| 2097 | func compareEvents(diff *MetadataDiff, _ string, oldSchema, newSchema *model.SchemaMetadata) { |
| 2098 | oldSchemaProto := oldSchema.GetProto() |
| 2099 | newSchemaProto := newSchema.GetProto() |
| 2100 | |
| 2101 | // Build maps of events |
| 2102 | oldEventMap := make(map[string]*storepb.EventMetadata) |
| 2103 | for _, event := range oldSchemaProto.Events { |
| 2104 | oldEventMap[event.Name] = event |
| 2105 | } |
| 2106 | |
| 2107 | newEventMap := make(map[string]*storepb.EventMetadata) |
| 2108 | for _, event := range newSchemaProto.Events { |
| 2109 | newEventMap[event.Name] = event |
| 2110 | } |
| 2111 | |
| 2112 | // Check for dropped events |
| 2113 | for eventName, oldEvent := range oldEventMap { |
| 2114 | if _, exists := newEventMap[eventName]; !exists { |
| 2115 | diff.EventChanges = append(diff.EventChanges, &EventDiff{ |
| 2116 | Action: MetadataDiffActionDrop, |
| 2117 | EventName: eventName, |
| 2118 | OldEvent: oldEvent, |
| 2119 | }) |
| 2120 | } |
| 2121 | } |
| 2122 | |
| 2123 | // Check for new and modified events |
| 2124 | for eventName, newEvent := range newEventMap { |
| 2125 | oldEvent, exists := oldEventMap[eventName] |
| 2126 | if !exists { |
| 2127 | diff.EventChanges = append(diff.EventChanges, &EventDiff{ |
| 2128 | Action: MetadataDiffActionCreate, |
| 2129 | EventName: eventName, |
| 2130 | NewEvent: newEvent, |
| 2131 | }) |
| 2132 | } else if oldEvent.Definition != newEvent.Definition { |
| 2133 | // Check if event has changed |
| 2134 | diff.EventChanges = append(diff.EventChanges, &EventDiff{ |
| 2135 | Action: MetadataDiffActionAlter, |
| 2136 | EventName: eventName, |
| 2137 | OldEvent: oldEvent, |
| 2138 | NewEvent: newEvent, |
| 2139 | }) |
| 2140 | } |
| 2141 | } |
| 2142 | } |
| 2143 | |
| 2144 | // FilterPostgresArchiveSchema filters out schema diff objects related to bbdataarchive schema. |
| 2145 | func FilterPostgresArchiveSchema(diff *MetadataDiff) *MetadataDiff { |
no test coverage detected