Skip to content

Commit 202c8c0

Browse files
committed
Check for temp as well
1 parent fcf167a commit 202c8c0

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

mysql_ch_replicator/clickhouse_api.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,6 @@ def get_databases(self):
117117
database_list = [row[0] for row in databases]
118118
return database_list
119119

120-
def table_exists(self, table_name):
121-
"""Check if a specific table exists in the current database"""
122-
if self.database not in self.get_databases():
123-
return False
124-
125-
query = f"EXISTS TABLE `{self.database}`.`{table_name}`"
126-
result = self.client.query(query)
127-
if result.result_rows and result.result_rows[0][0] == 1:
128-
return True
129-
return False
130-
131120
def validate_database_schema(self, expected_tables):
132121
"""Validates that all expected tables exist in the database and returns missing tables"""
133122
if self.database not in self.get_databases():

mysql_ch_replicator/db_replicator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def run(self):
180180

181181
if self.state.status != Status.NONE:
182182
# ensure target database still exists
183-
if self.target_database not in self.clickhouse_api.get_databases():
183+
if self.target_database not in self.clickhouse_api.get_databases() and f"{self.target_database}_tmp" not in self.clickhouse_api.get_databases():
184184
logger.warning(f'database {self.target_database} missing in CH')
185185
logger.warning('will run replication from scratch')
186186
self.state.remove()

0 commit comments

Comments
 (0)