Skip to content

Commit 5782125

Browse files
committed
Simple strategy to address #163. Update client and geodiff.
1 parent 112da7c commit 5782125

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ COPY requirements.txt /tmp/
2222
RUN pip3 install -r /tmp/requirements.txt
2323

2424
# geodiff is needed with PostgreSQL support - we have to compile it
25-
RUN git clone --branch 2.0.2 https://github.com/merginmaps/geodiff.git
25+
RUN git clone --branch 2.0.4 https://github.com/merginmaps/geodiff.git
2626
RUN cd geodiff && mkdir build && cd build && \
2727
cmake -DWITH_POSTGRESQL=TRUE ../geodiff && \
2828
make

dbsync.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

14431451
def 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

14551467
def 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

14621476
def 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

14691485
def 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

14761494
def 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

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
mergin-client==0.9.0
1+
mergin-client==0.10.5
22
dynaconf>=3.1
3-
psycopg2>=2.9
3+
psycopg2-binary>=2.9

0 commit comments

Comments
 (0)