File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -314,6 +314,15 @@ def enable_replica(self):
314
314
self .pg_engine .set_source_status ("stopped" )
315
315
self .pg_engine .end_maintenance ()
316
316
317
+ def copy_schema (self ):
318
+ """
319
+ The method calls init_replica adding a flag for skipping the data copy.
320
+ Useful if we want to test for schema issues or to populate the schema preventively.
321
+
322
+ """
323
+ self .mysql_source .copy_table_data = False
324
+ self .init_replica ()
325
+
317
326
def init_replica (self ):
318
327
"""
319
328
The method initialise a replica for a given source and configuration.
@@ -349,7 +358,7 @@ def __init_mysql_replica(self):
349
358
foreground = True
350
359
else :
351
360
foreground = False
352
- print ("Init replica process for source %s started." % (self .args .source ))
361
+ print ("Process for source %s started." % (self .args .source ))
353
362
keep_fds = [self .logger_fds ]
354
363
init_pid = os .path .expanduser ('%s/%s.pid' % (self .config ["pid_dir" ],self .args .source ))
355
364
self .logger .info ("Initialising the replica for source %s" % self .args .source )
@@ -369,7 +378,7 @@ def __init_pgsql_replica(self):
369
378
foreground = True
370
379
else :
371
380
foreground = False
372
- print ("Init replica process for source %s started." % (self .args .source ))
381
+ print ("Process for source %s started." % (self .args .source ))
373
382
keep_fds = [self .logger_fds ]
374
383
init_pid = os .path .expanduser ('%s/%s.pid' % (self .config ["pid_dir" ],self .args .source ))
375
384
self .logger .info ("Initialising the replica for source %s" % self .args .source )
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ def __init__(self):
27
27
self .schema_only = {}
28
28
self .gtid_mode = False
29
29
self .gtid_enable = False
30
+ self .copy_table_data = True
30
31
31
32
32
33
def __del__ (self ):
@@ -546,6 +547,8 @@ def get_master_coordinates(self):
546
547
:return: the master's log coordinates for the given table
547
548
:rtype: dictionary
548
549
"""
550
+ if not self .conn_buffered .open :
551
+ self .connect_db_buffered ()
549
552
sql_master = "SHOW MASTER STATUS;"
550
553
self .cursor_buffered .execute (sql_master )
551
554
master_status = self .cursor_buffered .fetchall ()
@@ -775,7 +778,11 @@ def __copy_tables(self):
775
778
self .pg_engine .truncate_table (destination_schema ,table )
776
779
master_status = self .copy_data (schema , table )
777
780
else :
778
- master_status = self .copy_data (schema , table )
781
+ if self .copy_table_data :
782
+ master_status = self .copy_data (schema , table )
783
+ else :
784
+ master_status = self .get_master_coordinates ()
785
+
779
786
table_pkey = self .__create_indices (schema , table )
780
787
self .pg_engine .store_table (destination_schema , table , table_pkey , master_status )
781
788
if self .keep_existing_schema :
You can’t perform that action at this time.
0 commit comments