I am using SymmetricDS
for first time and i have two table to sync.
1. Session_Tbl
:- this table sync from Store to Corp. I cant make session_tbl bidirection.
2. Products
:- This table sync in bidirection. Product Table is linked with Session_tbl with PRODUCTS_SESSION
FOREIGN KEY.
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;
When i insert data in store it sync to corp as well, becasue sesison_tbl will sync store to corp and product table is bidirectional. But when i insert any product in products table what time i am getting below exception because session id is not exist in store session_tbl:-
org.jumpmind.db.sql.SqlException: Cannot add or update a child row: a foreign key constraint fails
Is there any configuration in SymmetricDS
which can fetch the Foreign Key Data file sending product data?
EDIT
Added sym table data :-
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);
Thanks Anchit