@@ -721,7 +721,7 @@ def revert_local_changes(
721721 return leftovers
722722
723723
724- def pull (conn_cfg , mc ):
724+ def pull (conn_cfg , mc , id = 0 ):
725725 """Downloads any changes from Mergin Maps and applies them to the database"""
726726
727727 logging .debug (f"Processing Mergin Maps project '{ conn_cfg .mergin_project } '" )
@@ -731,7 +731,9 @@ def pull(conn_cfg, mc):
731731 work_dir = os .path .join (
732732 config .working_dir ,
733733 project_name ,
734+ f"{ id } "
734735 )
736+
735737 gpkg_full_path = os .path .join (
736738 work_dir ,
737739 conn_cfg .sync_file ,
@@ -868,7 +870,7 @@ def pull(conn_cfg, mc):
868870 )
869871
870872
871- def status (conn_cfg , mc ):
873+ def status (conn_cfg , mc , id = 0 ):
872874 """Figure out if there are any pending changes in the database or in Mergin Maps"""
873875
874876 logging .debug (f"Processing Mergin Maps project '{ conn_cfg .mergin_project } '" )
@@ -879,6 +881,7 @@ def status(conn_cfg, mc):
879881 work_dir = os .path .join (
880882 config .working_dir ,
881883 project_name ,
884+ f"{ id } "
882885 )
883886 gpkg_full_path = os .path .join (
884887 work_dir ,
@@ -967,7 +970,7 @@ def status(conn_cfg, mc):
967970 _print_changes_summary (summary )
968971
969972
970- def push (conn_cfg , mc ):
973+ def push (conn_cfg , mc , id = 0 ):
971974 """Take changes in the 'modified' schema in the database and push them to Mergin Maps"""
972975
973976 logging .debug (f"Processing Mergin Maps project '{ conn_cfg .mergin_project } '" )
@@ -986,6 +989,7 @@ def push(conn_cfg, mc):
986989 work_dir = os .path .join (
987990 config .working_dir ,
988991 project_name ,
992+ f"{ id } "
989993 )
990994 gpkg_full_path = os .path .join (
991995 work_dir ,
@@ -1076,6 +1080,7 @@ def init(
10761080 conn_cfg ,
10771081 mc ,
10781082 from_gpkg = True ,
1083+ id = 0
10791084):
10801085 """Initialize the dbsync so that it is possible to do two-way sync between Mergin Maps and a database"""
10811086
@@ -1109,11 +1114,14 @@ def init(
11091114 work_dir = os .path .join (
11101115 config .working_dir ,
11111116 project_name ,
1117+ f"{ id } "
11121118 )
1119+
11131120 gpkg_full_path = os .path .join (
11141121 work_dir ,
11151122 conn_cfg .sync_file ,
11161123 )
1124+
11171125 if modified_schema_exists and base_schema_exists :
11181126 logging .debug ("Modified and base schemas already exist" )
11191127 # this is not a first run of db-sync init
@@ -1442,35 +1450,45 @@ def init(
14421450
14431451def dbsync_init (mc ):
14441452 from_gpkg = config .init_from .lower () == "gpkg"
1453+ i = 0
14451454 for conn in config .connections :
14461455 init (
14471456 conn ,
14481457 mc ,
14491458 from_gpkg = from_gpkg ,
1459+ id = i
14501460 )
14511461
1462+ i += 1
1463+
14521464 logging .debug ("Init done!" )
14531465
14541466
14551467def dbsync_pull (mc ):
1468+ i = 0
14561469 for conn in config .connections :
1457- pull (conn , mc )
1470+ pull (conn , mc , id = i )
1471+ i += 1
14581472
14591473 logging .debug ("Pull done!" )
14601474
14611475
14621476def dbsync_push (mc ):
1477+ i = 0
14631478 for conn in config .connections :
1464- push (conn , mc )
1479+ push (conn , mc , id = i )
1480+ i += 1
14651481
14661482 logging .debug ("Push done!" )
14671483
14681484
14691485def dbsync_status (
14701486 mc ,
14711487):
1488+ i = 0
14721489 for conn in config .connections :
1473- status (conn , mc )
1490+ status (conn , mc , id = i )
1491+ i += 1
14741492
14751493
14761494def clean (conn_cfg , mc ):
@@ -1530,6 +1548,7 @@ def dbsync_clean(
15301548 for conn in config .connections :
15311549 clean (conn , mc )
15321550
1551+
15331552 logging .debug ("Cleaning done!" )
15341553
15351554
0 commit comments