@@ -24,10 +24,10 @@ func (c *ClickHouseConnector) ValidateMirrorDestination(
2424 }
2525 }
2626
27- peerDBColumns := []string {signColName , versionColName }
28- if cfg .SyncedAtColName != "" {
29- peerDBColumns = append (peerDBColumns , strings .ToLower (cfg .SyncedAtColName ))
27+ if cfg .Resync {
28+ return nil // no need to validate schema for resync, as we will create or replace the tables
3029 }
30+
3131 // this is for handling column exclusion, processed schema does that in a step
3232 processedMapping := internal .BuildProcessedSchemaMapping (cfg .TableMappings , tableNameSchemaMapping , c .logger )
3333 dstTableNames := slices .Collect (maps .Keys (processedMapping ))
@@ -46,7 +46,7 @@ func (c *ClickHouseConnector) ValidateMirrorDestination(
4646 return err
4747 }
4848
49- if ! ( cfg . Resync || sourceSchemaAsDestinationColumn ) {
49+ if ! sourceSchemaAsDestinationColumn {
5050 if err := chvalidate .CheckIfTablesEmptyAndEngine (ctx , c .logger , c .database ,
5151 dstTableNames , cfg .DoInitialSnapshot , internal .PeerDBOnlyClickHouseAllowed (), initialLoadAllowNonEmptyTables ,
5252 ); err != nil {
@@ -59,6 +59,11 @@ func (c *ClickHouseConnector) ValidateMirrorDestination(
5959 return err
6060 }
6161
62+ peerDBColumns := []string {signColName , versionColName }
63+ if cfg .SyncedAtColName != "" {
64+ peerDBColumns = append (peerDBColumns , strings .ToLower (cfg .SyncedAtColName ))
65+ }
66+
6267 for _ , tableMapping := range cfg .TableMappings {
6368 dstTableName := tableMapping .DestinationTableIdentifier
6469 if _ , ok := processedMapping [dstTableName ]; ! ok {
@@ -70,14 +75,12 @@ func (c *ClickHouseConnector) ValidateMirrorDestination(
7075 continue
7176 }
7277
73- if ! cfg .Resync {
74- // for resync, we don't need to check the content or structure of the original tables;
75- // they'll anyways get swapped out with the _resync tables which we CREATE OR REPLACE
76- if err := c .processTableComparison (dstTableName , processedMapping [dstTableName ],
77- chTableColumnsMapping [dstTableName ], peerDBColumns , tableMapping ,
78- ); err != nil {
79- return err
80- }
78+ // for resync, we don't need to check the content or structure of the original tables;
79+ // they'll anyways get swapped out with the _resync tables which we CREATE OR REPLACE
80+ if err := c .processTableComparison (dstTableName , processedMapping [dstTableName ],
81+ chTableColumnsMapping [dstTableName ], peerDBColumns , tableMapping ,
82+ ); err != nil {
83+ return err
8184 }
8285 }
8386 return nil
0 commit comments