create or replace view centile_check_connection.v_in_centile_user_account as select * from user_account_centile.user_account;


create or replace view centile_check_connection.v_in_centile_terminals as select * from centile_terminals.v_user_terminal_choose;


create or replace view centile_check_connection.v_in_user_account_alive as select * from centile_auth_user.v_out_user_account_alive;



CREATE OR REPLACE view centile_check_connection.v_out_centile_connection_check as
SELECT
    cua.is_active AS centile_init,
    CASE
        WHEN uaa.id IS NOT NULL THEN 'Y'
            ELSE 'N'
        END AS centile_auth,
    cua.id AS centile_user_account_id,
    cua.selfcare_user_id,
    ct.terminal_id AS centile_terminal_choose,
    ct.device_model
FROM `v_in_centile_user_account` cua
         LEFT JOIN `v_in_user_account_alive` uaa ON uaa.`centile_user_account_id` = cua.`id`
         LEFT JOIN `v_in_centile_terminals` ct ON ct.`centile_user_account_id` = cua.`id` ;
