@@ -178,4 +178,49 @@ func TestWHSchemasRepo(t *testing.T) {
178
178
require .NoError (t , err )
179
179
require .Equal (t , expiryTime , updatedSchema .ExpiresAt )
180
180
})
181
+
182
+ t .Run ("Insert schema propagation to all connections with same destination_id and namespace" , func (t * testing.T ) {
183
+ // Create first connection schema
184
+ firstConnectionSchema := schema
185
+ firstID , err := r .Insert (ctx , & firstConnectionSchema )
186
+ require .NoError (t , err )
187
+ firstConnectionSchema .ID = firstID
188
+
189
+ // Create second connection schema with same destination_id and namespace
190
+ secondConnectionSchema := firstConnectionSchema
191
+ secondConnectionSchema .SourceID = "other_source_id"
192
+ secondConnectionSchema .ID = 0 // Reset ID for new insert
193
+ secondID , err := r .Insert (ctx , & secondConnectionSchema )
194
+ require .NoError (t , err )
195
+ secondConnectionSchema .ID = secondID
196
+
197
+ // Verify both connections have the same initial schema
198
+ firstRetrieved , err := r .GetForNamespace (ctx , firstConnectionSchema .SourceID , firstConnectionSchema .DestinationID , firstConnectionSchema .Namespace )
199
+ require .NoError (t , err )
200
+ require .Equal (t , firstConnectionSchema .Schema , firstRetrieved .Schema )
201
+
202
+ secondRetrieved , err := r .GetForNamespace (ctx , secondConnectionSchema .SourceID , secondConnectionSchema .DestinationID , secondConnectionSchema .Namespace )
203
+ require .NoError (t , err )
204
+ require .Equal (t , firstConnectionSchema .Schema , secondRetrieved .Schema )
205
+
206
+ // Update the first connection with new schema data
207
+ updatedSchema := firstConnectionSchema
208
+ updatedSchema .Schema = model.Schema {
209
+ "new_table" : {
210
+ "new_column" : "string" ,
211
+ },
212
+ }
213
+ updatedSchema .ID = 0 // Reset ID for new insert
214
+ _ , err = r .Insert (ctx , & updatedSchema )
215
+ require .NoError (t , err )
216
+
217
+ // Verify both connections are updated with the new schema
218
+ firstRetrieved , err = r .GetForNamespace (ctx , firstConnectionSchema .SourceID , firstConnectionSchema .DestinationID , firstConnectionSchema .Namespace )
219
+ require .NoError (t , err )
220
+ require .Equal (t , updatedSchema .Schema , firstRetrieved .Schema )
221
+
222
+ secondRetrieved , err = r .GetForNamespace (ctx , secondConnectionSchema .SourceID , secondConnectionSchema .DestinationID , secondConnectionSchema .Namespace )
223
+ require .NoError (t , err )
224
+ require .Equal (t , updatedSchema .Schema , secondRetrieved .Schema )
225
+ })
181
226
}
0 commit comments