0

我是SymmetricDS第一次使用,我有两个表要同步。1. Session_Tbl:- 此表从 Store 同步到 Corp。我无法使 session_tbl 双向。2. Products:- 该表双向同步。PRODUCTS_SESSION产品表通过FOREIGN KEY与 Session_tbl 链接。

CREATE TABLE SESSION_TBL (
    SESSION_ID VARCHAR(45) NOT NULL,
    STATUS VARCHAR(15),
    CREATION_TIME DATETIME DEFAULT CURRENT_TIMESTAMP,
    MODIFICATION_TIME DATETIME ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (SESSION_ID)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    CREATE TABLE PRODUCTS (
    PRODUCT_ID VARCHAR(45) NOT NULL,
    REFERENCE VARCHAR(45) NOT NULL,
    CODE VARCHAR(100) NOT NULL,
    CODETYPE VARCHAR(10),
    NAME VARCHAR(100) NOT NULL, 
    SESSION_ID VARCHAR(45) NOT NULL,
    PRIMARY KEY (PRODUCT_ID),   
    CONSTRAINT PRODUCTS_SESSION FOREIGN KEY (SESSION_ID) REFERENCES SESSION_TBL(SESSION_ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

当我在存储中插入数据时,它也会同步到 corp,因为 sesison_tbl 会将存储同步到 corp 并且产品表是双向的。但是,当我在产品表中插入任何产品时,我何时会遇到异常,因为商店 session_tbl 中不存在会话 ID:-

org.jumpmind.db.sql.SqlException: Cannot add or update a child row: a foreign key constraint fails

是否有任何配置SymmetricDS可以获取发送产品数据的外键数据文件?

编辑

添加了符号表数据:-

insert into SYM_NODE (node_id, node_group_id, external_id, sync_enabled, created_at_node_id)
  values ('000', 'backoffice', '000', 1, 'server');

  insert into SYM_NODE (node_id, node_group_id, external_id, sync_enabled, created_at_node_id)
  values ('001', 'pos', '001', 1, 'server');

insert into SYM_NODE_IDENTITY values ('000');

insert into sym_node_security (node_id,node_password,registration_enabled,registration_time,initial_load_enabled,initial_load_time,created_at_node_id)
 values ('000','5d1c92bbacbe2edb9e1ca5dbb0e661',0,current_timestamp,0,current_timestamp,'server');

 insert into sym_node_security (node_id,node_password,registration_enabled,registration_time,initial_load_enabled,initial_load_time,created_at_node_id)
 values ('001','5d1c92bbacbe2edb9e1ca5dbb0e661',0,current_timestamp,0,current_timestamp,'server');

 -- CREATE GROUP 

 insert into SYM_NODE_GROUP
        (node_group_id, description)
        values ('pos', 'A retail pos node');

insert into SYM_NODE_GROUP
        (node_group_id, description)
        values ('backoffice', 'A backoffice node');

    -- CREATE GROUP LINK

insert into SYM_NODE_GROUP_LINK
(source_node_group_id, target_node_group_id, data_event_action)
      values ('pos', 'backoffice', 'P');

insert into SYM_NODE_GROUP_LINK
(source_node_group_id, target_node_group_id, data_event_action)
      values ('backoffice', 'pos', 'W');

    insert into SYM_CHANNEL (channel_id, processing_order, max_batch_size, max_batch_to_send,
             extract_period_millis, batch_algorithm,data_loader_type, enabled, description)
         values ('pos_to_backoffice_default', 1, 1000, 10, 0, 'default','default', 1, 'pos_to_backoffice_default one directional');


insert into SYM_TRIGGER (trigger_id, source_table_name,
          channel_id,sync_on_incoming_batch, last_update_time, create_time)
                  values ('pos_to_backoffice_default', 'SESSION_TBL', 'pos_to_backoffice_default',1, current_timestamp, current_timestamp);


     insert into SYM_CHANNEL (channel_id, processing_order, max_batch_size, max_batch_to_send,
         extract_period_millis, batch_algorithm,data_loader_type, enabled, description)
     values ('twoway_default', 10, 1000, 10, 0, 'default','default', 1, 'twoway_default bidirectional');

 insert into SYM_TRIGGER (trigger_id, source_table_name,
          channel_id,sync_on_incoming_batch, last_update_time, create_time)
                  values ('twoway_default', 'PRODUCTS', 'twoway_default',1, current_timestamp, current_timestamp);

insert into SYM_TRIGGER_ROUTER
        (trigger_id, router_id, initial_load_order, create_time,
        last_update_time) values ('pos_to_backoffice_default', 'pos-2-backoffice', 1, current_timestamp,
        current_timestamp);

        insert into SYM_TRIGGER_ROUTER
        (trigger_id, router_id, initial_load_order, create_time,
        last_update_time) values ('twoway_default', 'backoffice-2-pos', 1, current_timestamp,
        current_timestamp);

        insert into SYM_TRIGGER_ROUTER
        (trigger_id, router_id, initial_load_order, create_time,
        last_update_time) values ('twoway_default', 'pos-2-backoffice', 1, current_timestamp,
        current_timestamp);

insert into SYM_ROUTER (router_id,
        source_node_group_id, target_node_group_id,router_type, create_time,
        last_update_time) values ('backoffice-2-pos','backoffice', 'pos','default',
        current_timestamp, current_timestamp);

              insert into SYM_ROUTER (router_id,
        source_node_group_id, target_node_group_id,router_type, create_time,
        last_update_time) values ('pos-2-backoffice','pos', 'backoffice','default',
        current_timestamp, current_timestamp);

谢谢安奇特

4

0 回答 0