
-- Bancos_poliza
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`Bancos_poliza` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.Bancos_poliza TO `administrative`;
GRANT SELECT ON TABLE vn.bankPolicy TO `administrative`;

-- Entradas_orden
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`Entradas_orden` AS
SELECT 1;

GRANT SELECT,INSERT,DELETE ON TABLE vn2008.Entradas_orden TO `buyer`;
GRANT SELECT,INSERT,DELETE ON TABLE vn.entryOrder TO `buyer`;

-- Proveedores_gestdoc
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`Proveedores_gestdoc` AS
SELECT 1;

GRANT SELECT,INSERT,DELETE ON TABLE vn2008.Proveedores_gestdoc TO `administrative`;
GRANT SELECT ON TABLE vn2008.Proveedores_gestdoc TO `buyer`;
GRANT SELECT,INSERT ON TABLE vn2008.Proveedores_gestdoc TO `hr`;

GRANT SELECT,INSERT,DELETE ON TABLE vn.supplierDms TO `administrative`;
GRANT SELECT ON TABLE vn.supplierDms TO `buyer`;
GRANT SELECT,INSERT ON TABLE vn.supplierDms TO `hr`;

-- Remesas
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`Remesas` AS
SELECT 1;

GRANT SELECT,INSERT ON TABLE vn2008.Remesas TO `financial`;
GRANT SELECT,INSERT ON TABLE vn.remittance TO `financial`;

-- Vehiculos_consumo
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`Vehiculos_consumo` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.Vehiculos_consumo TO `administrative`;
GRANT INSERT,UPDATE,DELETE ON TABLE vn2008.Vehiculos_consumo TO `productionAssi`;

GRANT SELECT ON TABLE vn.vehicleConsumption TO `adminOfficer`;
GRANT INSERT,UPDATE,DELETE ON TABLE vn.vehicleConsumption TO `productionAssi`;

-- account_conciliacion
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`account_conciliacion` AS
SELECT 1;

GRANT SELECT,INSERT,DELETE ON TABLE vn2008.account_conciliacion TO `financial`;
GRANT SELECT,INSERT,DELETE ON TABLE vn.accountReconciliation TO `financial`;

-- account_detail
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`account_detail` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.account_detail TO `financial`;
GRANT SELECT ON TABLE vn2008.account_detail TO `hr`;

GRANT SELECT ON TABLE vn.accountDetail TO `financial`;
GRANT SELECT ON TABLE vn.accountDetail TO `hr`;

-- account_detail_type
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`account_detail_type` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.account_detail_type TO `hr`;
GRANT SELECT ON TABLE vn.accountDetailType TO `hr`;

-- airline
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`airline` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.airline TO `administrative`;
GRANT SELECT,UPDATE ON TABLE vn2008.airline TO `logistic`;

GRANT SELECT ON TABLE vn.airline TO `administrative`;
GRANT SELECT,UPDATE ON TABLE vn.airline TO `logistic`;

-- airport
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`airport` AS
SELECT 1;

GRANT SELECT,INSERT,UPDATE ON TABLE vn2008.airport TO `logistic`;
GRANT SELECT,INSERT,UPDATE ON TABLE vn.airport TO `logistic`;

-- albaran
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`albaran` AS
SELECT 1;

GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE vn2008.albaran TO `administrative`;
GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE vn.deliveryNote TO `administrative`;

-- albaran_gestdoc
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`albaran_gestdoc` AS
SELECT 1;

GRANT SELECT,INSERT ON TABLE vn2008.albaran_gestdoc TO `administrative`;
GRANT SELECT,INSERT ON TABLE vn.deliveryNoteDms TO `administrative`;

-- albaran_state
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`albaran_state` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.albaran_state TO `administrative`;
GRANT SELECT ON TABLE vn.deliveryNoteState TO `administrative`;

-- awb_component
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`awb_component` AS
SELECT 1;

GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE vn2008.awb_component TO `buyer`;
GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE vn2008.awb_component TO `logistic`;
GRANT SELECT ON TABLE vn2008.awb_component TO `administrative`;

GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE vn.awbComponent TO `buyer`;
GRANT SELECT,INSERT,UPDATE,DELETE ON TABLE vn.awbComponent TO `logistic`;
GRANT SELECT ON TABLE vn.awbComponent TO `administrative`;

-- awb_component_template
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`awb_component_template` AS
SELECT 1;

GRANT SELECT,INSERT,UPDATE ON TABLE vn2008.awb_component_template TO `logistic`;
GRANT SELECT,INSERT,UPDATE ON TABLE vn.awbComponentTemplate TO `logistic`;

-- awb_component_type
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`awb_component_type` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.awb_component_type TO `administrative`;
GRANT SELECT,UPDATE ON TABLE vn2008.awb_component_type TO `logistic`;

GRANT SELECT ON TABLE vn.awbComponentType TO `administrative`;
GRANT SELECT,UPDATE ON TABLE vn.awbComponentType TO `logistic`;

-- awb_gestdoc
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`awb_gestdoc` AS
SELECT 1;

GRANT SELECT,INSERT ON TABLE vn2008.awb_gestdoc TO `buyer`;
GRANT SELECT ON TABLE vn2008.awb_gestdoc TO `administrative`;
GRANT INSERT ON TABLE vn2008.awb_gestdoc TO `logistic`;
GRANT SELECT ON TABLE vn2008.awb_gestdoc TO `hr`;

GRANT SELECT,INSERT ON TABLE vn.awbDms TO `buyer`;
GRANT SELECT ON TABLE vn.awbDms TO `administrative`;
GRANT INSERT ON TABLE vn.awbDms TO `logistic`;
GRANT SELECT ON TABLE vn.awbDms TO `hr`;

-- awb_recibida
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`awb_recibida` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.awb_recibida TO `administrative`;
GRANT SELECT ON TABLE vn2008.awb_recibida TO `hrBoss`;

GRANT SELECT ON TABLE vn.awbInvoiceIn TO `administrative`;
GRANT SELECT ON TABLE vn.awbInvoiceIn TO `hrBoss`;

-- awb_role
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`awb_role` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.awb_role TO `logistic`;
GRANT SELECT ON TABLE vn.awbRole TO `logistic`;

-- awb_unit
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`awb_unit` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.awb_unit TO `logistic`;
GRANT SELECT ON TABLE vn.awbUnit TO `logistic`;

-- balance_nest_tree
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`balance_nest_tree` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.balance_nest_tree TO `financialBoss`;
GRANT SELECT ON TABLE vn.balanceNestTree TO `financialBoss`;

-- buy_edi_k012
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`buy_edi_k012` AS
SELECT 1;

CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `edi`.`ektK2` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.buy_edi_k012 TO `buyer`;
GRANT SELECT ON TABLE vn2008.buy_edi_k012 TO `administrative`;

GRANT SELECT ON TABLE edi.ektK1 TO `buyer`;
GRANT SELECT ON TABLE edi.ektK1 TO `administrative`;

GRANT SELECT ON TABLE edi.ektK2 TO `buyer`;
GRANT SELECT ON TABLE edi.ektK2 TO `administrative`;

-- buy_edi_k03
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`buy_edi_k03` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.buy_edi_k03 TO `buyer`;
GRANT SELECT ON TABLE vn2008.buy_edi_k03 TO `administrative`;

GRANT SELECT ON TABLE edi.ektK3 TO `buyer`;
GRANT SELECT ON TABLE edi.ektK3 TO `administrative`;

-- buy_edi_k04
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`buy_edi_k04` AS
SELECT 1;

GRANT SELECT ON TABLE vn2008.buy_edi_k04 TO `buyer`;
GRANT SELECT ON TABLE vn2008.buy_edi_k04 TO `administrative`;

GRANT SELECT ON TABLE edi.ektK4 TO `buyer`;
GRANT SELECT ON TABLE edi.ektK4 TO `administrative`;

-- definitivo
CREATE OR REPLACE DEFINER=`root`@`localhost`
	SQL SECURITY DEFINER
	VIEW `vn2008`.`definitivo` AS
SELECT 1;

GRANT SELECT,INSERT ON TABLE vn2008.definitivo TO `productionAssi`;
GRANT SELECT ON TABLE vn.dmsStorageBox TO `productionAssi`;
