-- noinspection SqlNoDataSourceInspectionForFile
START TRANSACTION;


INSERT INTO iret_from_napi.customer( `id`,`name`,`partner_id`,`recordings_enabled` )
SELECT  `id`,`name`,`partner_id`,`recordings_enabled`
FROM FROM_NAPI_V3_SAS.`customer`
WHERE id not IN(select id FROM iret_from_napi.customer) ;


INSERT INTO iret_from_napi.site(`id`, `customer_id`)
SELECT `id`, `customer_id`
FROM FROM_NAPI_V3_SAS.site WHERE
        id not IN(select id FROM iret_from_napi.site);

INSERT INTO iret_from_napi.ext_group_ext_centrex(`id`, `customer_id`,extension,label ,parent,user_auth_id )
SELECT `id`, `customer_id`,extension,label ,parent,user_auth_id
FROM FROM_NAPI_V3_SAS.ext_group_ext_centrex WHERE
        id not IN(select id FROM iret_from_napi.ext_group_ext_centrex);



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


INSERT INTO iret_from_napi.ext_extension_user_centrex(`id`, site_id, `user_id`, `number`,`userExt_id`, parent)
SELECT `id`, site_id, `user_id`, `number`,`userExt_id`, parent
FROM FROM_NAPI_V3_SAS.ext_extension_user_centrex WHERE
        id not IN(select id FROM iret_from_napi.ext_extension_user_centrex);





COMMIT;
