I have a server and few clients with databases sinchronized by Simmetric-DS.
Now the database version is 1.0 for client and server. So the column node.schema_version
is 1.0 for clients and server.
I can upgrade the server database manually to rev.2.0. The client databases will self-upgrade to rev.2.0 using another application.
I want to use node.schema_version
to avoid synchronization between
the server and the nodes with version different from 2.0.
I used a subselect router with this router_expression
:
'(SELECT check_version(c.schema_version))'
.. where the function check_version
is true if client server version are equal, otherwise raises an exception to stop the synchronization:
CREATE OR REPLACE FUNCTION check_version(v_ver_check text)
RETURNS boolean AS
$BODY$
DECLARE
v_ver_cur text;
v_success boolean;
BEGIN
v_success:=false;
v_ver_cur:='';
SELECT n.schema_version
FROM sym_node n
INNER JOIN sym_node_identity ni on n.node_id=ni.node_id
INTO v_ver_cur;
IF v_ver_cur=v_ver_check
THEN
v_success:=true;
ELSE
RAISE EXCEPTION 'SERVER-DB-VERSION<>CLIENT-DB-VERSION';
END IF;
RETURN v_success;
END;
$BODY$
LANGUAGE plpgsql VOLATILE STRICT
COST 1;
In case of version mismatch:
During upload data from client to server:
This approach works fine because the exception blocks the synchronization process on the client ONLY.During download data from server to client: The exception blocks the synchronization process ON THE SERVER so the synchronization is blocked versus ALL clients.
How I can block the download process only versus the node with version=1.0
?