/**
* Cambios para evitar fallos en local. 
* Ya está en producción
**/

ALTER TABLE `vn2008`.`Clientes` 
ADD COLUMN `bankEntityFk` INT(10) UNSIGNED NULL AFTER `hasLcr`;

USE `vn`;
CREATE 
     OR REPLACE ALGORITHM = UNDEFINED 
    DEFINER = `root`@`%` 
    SQL SECURITY DEFINER
VIEW `client` AS
    SELECT 
        `c`.`id_cliente` AS `id`,
        `c`.`cliente` AS `name`,
        `c`.`if` AS `fi`,
        `c`.`razonSocial` AS `socialName`,
        `c`.`contacto` AS `contact`,
        `c`.`domicilio` AS `street`,
        `c`.`poblacion` AS `city`,
        `c`.`codPostal` AS `postcode`,
        `c`.`telefono` AS `phone`,
        `c`.`movil` AS `mobile`,
        `c`.`fax` AS `fax`,
        `c`.`real` AS `isRelevant`,
        `c`.`e-mail` AS `email`,
        `c`.`iban` AS `iban`,
        `c`.`vencimiento` AS `dueDay`,
        `c`.`Cuenta` AS `accountingAccount`,
        `c`.`RE` AS `isEqualizated`,
        `c`.`province_id` AS `provinceFk`,
        `c`.`invoice` AS `hasToInvoice`,
        `c`.`credito` AS `credit`,
        `c`.`Id_Pais` AS `countryFk`,
        `c`.`activo` AS `isActive`,
        `c`.`gestdoc_id` AS `gestdocFk`,
        `c`.`calidad` AS `quality`,
        `c`.`pay_met_id` AS `payMethodFk`,
        `c`.`created` AS `created`,
        `c`.`mail` AS `isToBeMailed`,
        `c`.`chanel_id` AS `contactChannelFk`,
        `c`.`sepaVnl` AS `hasSepaVnl`,
        `c`.`coreVnl` AS `hasCoreVnl`,
        `c`.`coreVnh` AS `hasCoreVnh`,
        `c`.`hasLcr` AS `hasLcr`,
        `c`.`default_address` AS `defaultAddressFk`,
        `c`.`risk_calculated` AS `riskCalculated`,
        `c`.`clientes_tipo_id` AS `clientTypeFk`,
        `c`.`mail_address` AS `mailAddress`,
        `c`.`cplusTerIdNifFk` AS `cplusTerIdNifFk`,
        `c`.`invoiceByAddress` AS `hasToInvoiceByAddress`,
        `c`.`contabilizado` AS `isTaxDataChecked`,
        `c`.`congelado` AS `isFreezed`,
        `c`.`creditInsurance` AS `creditInsurance`,
        `c`.`isCreatedAsServed` AS `isCreatedAsServed`,
        `c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,
        `c`.`Id_Trabajador` AS `salesPersonFk`,
        `c`.`vies` AS `isVies`,
        `c`.`EYPBC` AS `eypbc`,
        bankEntityFk
    FROM
        `vn2008`.`Clientes` `c`;
