-- noinspection SqlNoDataSourceInspectionForFile
START TRANSACTION;


INSERT INTO napi.customer( `id`,`name`, `phone_bridge_enabled`)
SELECT  `id`,`name`, `phone_bridge_enabled`
FROM FROM_NAPI_V3_SAS.`customer`
WHERE id not IN(select id FROM napi.customer) ;


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



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



INSERT INTO napi.ext_user_centrex(`id`,`login`, `password`, customCallerID)
SELECT `id`,`login`, `password`,customCallerID
FROM FROM_NAPI_V3_SAS.ext_user_centrex WHERE
        id not IN(select id FROM napi.ext_user_centrex);







INSERT INTO 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 napi.ext_extension_user_centrex);



INSERT INTO napi.sda(`id`, ext_extension_user_centrex_id, `number`)
SELECT `id`, ext_extension_user_centrex_id, `number`
FROM FROM_NAPI_V3_SAS.sda WHERE
    id not IN(select id FROM napi.sda);


COMMIT;
