Menu

Sync multiple clients Android

Help
San RD
2016-08-15
2016-08-31
  • San RD

    San RD - 2016-08-15

    Hi!...
    I would like to know how to do this:
    I have one server with Postgres and one client on Android and everything is ok...
    The problem is when i add another client with different external id, the data is updated by the second device because the primary keys are the same.
    I want to preserve the data consistent.
    I read about of transforms but, how is the configuration?
    Not is clear for me

    Thanks!

     
  • Mark Michalek

    Mark Michalek - 2016-08-17

    Hi,

    Probably the easiest way to solve this is to add an node Id column to your table on the server side. Then you could add a transform that adds the node ID to the outgoing data, and mark that node ID as part of the primary key in the transform. That way, SymmetricDS would treat the node id as part of the primary key whether it truly is or not.

    Here is an example that shows added the node_id to a table called sale_transaction. sale_transaction has a primary key of tran_id.

    insert into SYM_TRANSFORM_TABLE (TRANSFORM_ID, SOURCE_NODE_GROUP_ID, TARGET_NODE_GROUP_ID, TRANSFORM_POINT, SOURCE_CATALOG_NAME, SOURCE_SCHEMA_NAME, SOURCE_TABLE_NAME, TARGET_CATALOG_NAME, TARGET_SCHEMA_NAME, TARGET_TABLE_NAME, UPDATE_FIRST, UPDATE_ACTION, DELETE_ACTION, TRANSFORM_ORDER, COLUMN_POLICY, CREATE_TIME, LAST_UPDATE_BY, LAST_UPDATE_TIME) values ('sale_trans_add_node_id','store','corp','EXTRACT',null,null,'sale_transaction',null,null,'sale_transaction',0,'UPD_ROW','DEL_ROW',0,'IMPLIED',{ts '2016-08-17 12:31:56.601'},'no_user',{ts '2016-08-17 12:43:56.014'});
    insert into SYM_TRANSFORM_COLUMN (TRANSFORM_ID, INCLUDE_ON, TARGET_COLUMN_NAME, SOURCE_COLUMN_NAME, PK, TRANSFORM_TYPE, TRANSFORM_EXPRESSION, TRANSFORM_ORDER, CREATE_TIME, LAST_UPDATE_BY, LAST_UPDATE_TIME) values ('sale_trans_add_node_id','','TRAN_ID','TRAN_ID',1,'copy',null,1,{ts '2016-08-17 12:43:56.022'},null,{ts '2016-08-17 12:43:56.022'});
    insert into SYM_TRANSFORM_COLUMN (TRANSFORM_ID, INCLUDE_ON, TARGET_COLUMN_NAME, SOURCE_COLUMN_NAME, PK, TRANSFORM_TYPE, TRANSFORM_EXPRESSION, TRANSFORM_ORDER, CREATE_TIME, LAST_UPDATE_BY, LAST_UPDATE_TIME) values ('sale_trans_add_node_id','
    ','NODE_ID',null,1,'variable','source_node_id',2,{ts '2016-08-17 12:43:56.023'},null,{ts '2016-08-17 12:43:56.023'});

     
  • San RD

    San RD - 2016-08-17

    Great! Thanks por the reply.
    I will try :)

     
  • Iñaki Berra

    Iñaki Berra - 2016-08-24

    Hey San, could you make it work?

    One question Mark. What is the difference just to add it on the server side or have the node_id in both databases? I see no difference, but I think the syncronization would be much easier if all the databases where the same. If you only have the node_id in the server, then you have a different schema on the nodes, am i right? then it would be much easier to have the node_id in both sides.

     
  • Mark Michalek

    Mark Michalek - 2016-08-31

    Iñaki, yes I agree it would be ideal to have the node_id column on both sides, and have the schema the same. The above solution is helpful is for some reason you can only change one side.

    Mark

     

Log in to post a comment.