-- noinspection SqlNoDataSourceInspectionForFile
START TRANSACTION;


INSERT INTO wbsv2_from_napi.SAS_CUSTOMER(`id`, `name`,`id_partner`, `key_wbs`, `key_selfcare`)
SELECT `id`, `name`,`id_partner`, `key_wbs`, `key_selfcare` FROM FROM_NAPI_V3_SAS.ise_customer
WHERE id not IN(select id FROM wbsv2_from_napi.SAS_CUSTOMER) ;





INSERT INTO wbsv2_from_napi.SAS_SITE(`id`, `name`, `id_customer`, `key_wbs`, `key_selfcare`)
SELECT `id`, `name`, `id_customer` ,`key_wbs`, `key_selfcare` FROM FROM_NAPI_V3_SAS.ise_site WHERE
 id not IN(select id FROM wbsv2_from_napi.SAS_SITE);



INSERT INTO wbsv2_from_napi.SAS_USER(`id`, `username`,employeeTypeBdd,site_id)
SELECT `id`, `username`,employeeTypeBdd,site_id FROM FROM_NAPI_V3_SAS.user WHERE
        id not IN(select id FROM wbsv2_from_napi.SAS_USER);






INSERT INTO wbsv2_from_napi.SAS_GROUP_EXT(`id`,`customer_id`,`user_auth_id`)
SELECT  `id`,`customer_id`,`user_auth_id` FROM FROM_NAPI_V3_SAS.ext_group_ext_centrex WHERE
        id not IN(select id FROM wbsv2_from_napi.SAS_GROUP_EXT);


INSERT INTO aclstore.user(`id`, `name`)
SELECT `id`, `username`
FROM FROM_NAPI_V3_SAS.user WHERE
        id not IN(select id FROM aclstore.user);

COMMIT;
