CREATE ROLE 'salix', 'android', 'hedera-web', 'grafana';

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'salix'@'10.0.%.%', 'android'@'10.0.%.%', 'hedera-web'@'10.0.%.%', 'grafana'@'10.0.%.%';

GRANT 'salix' TO 'salix'@'10.0.%.%';
GRANT 'android' TO 'android'@'10.0.%.%';
GRANT 'hedera-web' TO 'hedera-web'@'10.0.%.%';
GRANT 'grafana' TO 'grafana'@'10.0.%.%';

SET DEFAULT ROLE 'salix' FOR 'salix'@'10.0.%.%';
SET DEFAULT ROLE 'android' FOR 'android'@'10.0.%.%';
SET DEFAULT ROLE 'hedera-web' FOR 'hedera-web'@'10.0.%.%';
SET DEFAULT ROLE 'grafana' FOR 'grafana'@'10.0.%.%';

-- salix
        -- GRANT `$root` TO `salix` WITH ADMIN OPTION; Access denied for user 'root'@'%'
GRANT CREATE USER ON *.* TO `salix` WITH GRANT OPTION;
GRANT SELECT, UPDATE ON `mysql`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE, EVENT ON `account`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `bs`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `util`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `pbx`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE, EVENT ON `vn`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `salix`.* TO `salix`;
GRANT SELECT ON `managedesktop`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `edi`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn2008`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `tmp`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `sage`.* TO `salix`;
GRANT SELECT, CREATE TEMPORARY TABLES, EXECUTE ON `cache`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `nst`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `hedera`.* TO `salix`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `postgresql`.* TO `salix`;

-- android
GRANT USAGE ON *.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `android`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `vn`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `cache`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `hedera`.* TO `android`;
GRANT SELECT, EXECUTE ON `pbx`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE TEMPORARY TABLES ON `tmp`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn2008`.* TO `android`;
GRANT SELECT ON `edi`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `account`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, SHOW VIEW ON `bi`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `Consumos`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vncontrol`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `srt`.* TO `android`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `psico`.* TO `android`;
GRANT SELECT ON `salix`.`AccessToken` TO `android`;
GRANT EXECUTE ON PROCEDURE `util`.`debugadd` TO `android`;
GRANT EXECUTE ON PROCEDURE `util`.`log_add` TO `android`;
GRANT EXECUTE ON FUNCTION `util`.`vn_now` TO `android`;

-- hedera-web
GRANT USAGE ON *.* TO `hedera-web`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `stock`.* TO `hedera-web`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn`.* TO `hedera-web`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `hedera`.* TO `hedera-web`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `account`.* TO `hedera-web`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `vn2008`.* TO `hedera-web`;
GRANT SELECT ON `util`.* TO `hedera-web`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `edi`.* TO `hedera-web`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE TEMPORARY TABLES, EXECUTE ON `salix`.* TO `hedera-web`;

-- grafana
GRANT USAGE ON *.* TO `grafana` WITH MAX_USER_CONNECTIONS 50;
GRANT EXECUTE ON `util`.* TO `grafana`;
GRANT SELECT ON `vn`.`mistakeType` TO `grafana`;
GRANT SELECT ON `vn`.`collectionHotbed` TO `grafana`;
GRANT SELECT ON `bs`.`clientDied` TO `grafana`;
GRANT SELECT ON `vn`.`expeditionScan` TO `grafana`;
GRANT SELECT ON `vn`.`sale` TO `grafana`;
GRANT SELECT ON `vn`.`printQueue` TO `grafana`;
GRANT SELECT ON `vn`.`operator` TO `grafana`;
GRANT SELECT ON `vn`.`itemType` TO `grafana`;
GRANT SELECT ON `vn`.`expedition` TO `grafana`;
GRANT SELECT ON `srt`.`bufferState` TO `grafana`;
GRANT SELECT ON `edi`.`offerList` TO `grafana`;
GRANT SELECT ON `vn`.`creditInsurance` TO `grafana`;
GRANT SELECT ON `vn`.`workerTimeControl` TO `grafana`;
GRANT SELECT ON `vn`.`volumeConfig` TO `grafana`;
GRANT SELECT ON `vn`.`agency` TO `grafana`;
GRANT SELECT ON `vn`.`alertLevel` TO `grafana`;
GRANT SELECT (user_id, extension) ON `pbx`.`sip` TO `grafana`;
GRANT SELECT ON `vn`.`expeditionStateType` TO `grafana`;
GRANT SELECT ON `vn`.`businessType` TO `grafana`;
GRANT SELECT ON `vn`.`time` TO `grafana`;
GRANT SELECT ON `hedera`.`visitUser` TO `grafana`;
GRANT SELECT ON `vn`.`workCenter` TO `grafana`;
GRANT SELECT ON `vn`.`ticket` TO `grafana`;
GRANT SELECT ON `vn`.`ticketWeekly` TO `grafana`;
GRANT SELECT ON `vn`.`claimEnd` TO `grafana`;
GRANT SELECT ON `vn`.`arcRead` TO `grafana`;
GRANT SELECT ON `vn`.`saleGoal` TO `grafana`;
GRANT SELECT ON `edi`.`supplyResponse` TO `grafana`;
GRANT SELECT ON `vn`.`invoiceInTax` TO `grafana`;
GRANT SELECT ON `bs`.`salesPersonEvolution` TO `grafana`;
GRANT SELECT ON `vn`.`saleComponent` TO `grafana`;
GRANT SELECT ON `vn`.`itemShelvingStock` TO `grafana`;
GRANT SELECT ON `vn`.`clientChain` TO `grafana`;
GRANT SELECT ON `edi`.`VMPSettings` TO `grafana`;
GRANT SELECT ON `util`.`debug` TO `grafana`;
GRANT SELECT ON `vn`.`claimResponsible` TO `grafana`;
GRANT SELECT ON `vn`.`ticketState` TO `grafana`;
GRANT SELECT ON `vn`.`packingSiteLog` TO `grafana`;
GRANT SELECT ON `bs`.`sale` TO `grafana`;
GRANT SELECT ON `vn`.`ink` TO `grafana`;
GRANT SELECT ON `bs`.`inventoryDiscrepancyDetail` TO `grafana`;
GRANT SELECT ON `vn`.`clientCredit` TO `grafana`;
GRANT SELECT ON `vn`.`workerMana` TO `grafana`;
GRANT SELECT ON `vn`.`greugeType` TO `grafana`;
GRANT SELECT ON `vn`.`supplierPackaging` TO `grafana`;
GRANT SELECT ON `vn`.`mdbVersion` TO `grafana`;
GRANT SELECT ON `vn`.`clientLog` TO `grafana`;
GRANT SELECT ON `vn`.`calendar` TO `grafana`;
GRANT SELECT ON `vn`.`campaign` TO `grafana`;
GRANT SELECT ON `vn`.`ticketService` TO `grafana`;
GRANT SELECT ON `vn`.`report` TO `grafana`;
GRANT SELECT ON `vn`.`buyer` TO `grafana`;
GRANT SELECT ON `bs`.`defaulter` TO `grafana`;
GRANT SELECT ON `vn`.`componentType` TO `grafana`;
GRANT SELECT ON `vn`.`clientManaCache` TO `grafana`;
GRANT SELECT ON `vn`.`invoiceIn` TO `grafana`;
GRANT SELECT ON `edi`.`deliveryInformation` TO `grafana`;
GRANT SELECT ON `srt`.`bufferType` TO `grafana`;
GRANT SELECT ON `account`.`role` TO `grafana`;
GRANT SELECT ON `edi`.`supplyOffer` TO `grafana`;
GRANT SELECT ON `vn`.`travel` TO `grafana`;
GRANT SELECT ON `srt`.`bufferFreeLength` TO `grafana`;
GRANT SELECT ON `vn`.`worker` TO `grafana`;
GRANT SELECT ON `vn`.`client` TO `grafana`;
GRANT SELECT ON `vn`.`supplier` TO `grafana`;
GRANT SELECT ON `vn`.`zoneEstimatedDelivery` TO `grafana`;
GRANT SELECT ON `vn`.`workerDistributionCategory` TO `grafana`;
GRANT SELECT ON `vn`.`entry` TO `grafana`;
GRANT SELECT ON `vn`.`claimBeginning` TO `grafana`;
GRANT SELECT ON `vn`.`payMethod` TO `grafana`;
GRANT SELECT ON `vn`.`collection` TO `grafana`;
GRANT SELECT ON `srt`.`routePalletized` TO `grafana`;
GRANT SELECT ON `bs`.`inventoryDiscrepancy` TO `grafana`;
GRANT SELECT ON `vn`.`itemImageQueue` TO `grafana`;
GRANT SELECT ON `bi`.`rutasBoard` TO `grafana`;
GRANT SELECT ON `vn`.`department` TO `grafana`;
GRANT SELECT ON `bs`.`workerLabourDataByMonth` TO `grafana`;
GRANT SELECT ON `vn`.`route` TO `grafana`;
GRANT SELECT ON `vn`.`routeCommission` TO `grafana`;
GRANT SELECT ON `bs`.`m3` TO `grafana`;
GRANT SELECT ON `vn`.`itemCost` TO `grafana`;
GRANT SELECT ON `vn`.`zone` TO `grafana`;
GRANT SELECT ON `vn`.`mdbApp` TO `grafana`;
GRANT SELECT ON `vn`.`ticketPackaging` TO `grafana`;
GRANT SELECT ON `vn`.`itemTaxCountry` TO `grafana`;
GRANT SELECT ON `vn`.`sectorCollection` TO `grafana`;
GRANT SELECT ON `vn`.`address` TO `grafana`;
GRANT SELECT ON `vn`.`deviceProductionLog` TO `grafana`;
GRANT SELECT ON `vn`.`itemPackingType` TO `grafana`;
GRANT SELECT ON `vn`.`workerJourney` TO `grafana`;
GRANT SELECT ON `srt`.`expedition` TO `grafana`;
GRANT SELECT ON `vn`.`expeditionMistake` TO `grafana`;
GRANT SELECT ON `vn`.`productionError` TO `grafana`;
GRANT SELECT ON `vn`.`expeditionState` TO `grafana`;
GRANT SELECT ON `bs`.`salesByItemTypeDay` TO `grafana`;
GRANT SELECT ON `vn`.`packingSite` TO `grafana`;
GRANT SELECT ON `vn`.`businessCalendar` TO `grafana`;
GRANT SELECT ON `vn`.`chain` TO `grafana`;
GRANT SELECT ON `vn`.`clientRisk` TO `grafana`;
GRANT SELECT ON `vn`.`claimRedelivery` TO `grafana`;
GRANT SELECT ON `vn`.`business` TO `grafana`;
GRANT SELECT ON `bs`.`clientAnnualConsumption` TO `grafana`;
GRANT SELECT ON `vn`.`dock` TO `grafana`;
GRANT SELECT ON `vn`.`item` TO `grafana`;
GRANT SELECT ON `vn`.`province` TO `grafana`;
GRANT SELECT ON `vn`.`shelving` TO `grafana`;
GRANT SELECT ON `vn`.`claim` TO `grafana`;
GRANT SELECT ON `vn`.`clientType` TO `grafana`;
GRANT SELECT ON `vn`.`supplierAccount` TO `grafana`;
GRANT SELECT ON `vn`.`workerDepartment` TO `grafana`;
GRANT SELECT ON `pbx`.`cdr` TO `grafana`;
GRANT SELECT ON `vn`.`workerTimeControlConfig` TO `grafana`;
GRANT SELECT ON `vn`.`workerMistake` TO `grafana`;
GRANT SELECT ON `edi`.`putOrder` TO `grafana`;
GRANT SELECT ON `vn`.`saleMistake` TO `grafana`;
GRANT SELECT ON `vn`.`deviceProductionUser` TO `grafana`;
GRANT SELECT ON `vn`.`contactChannel` TO `grafana`;
GRANT SELECT ON `vn`.`deviceLog` TO `grafana`;
GRANT SELECT ON `vn`.`vehicle` TO `grafana`;
GRANT SELECT ON `vn`.`packaging` TO `grafana`;
GRANT SELECT ON `bs`.`workerProductivityConfig` TO `grafana`;
GRANT SELECT ON `srt`.`antenna` TO `grafana`;
GRANT SELECT ON `vn`.`cmr` TO `grafana`;
GRANT SELECT ON `vn`.`accounting` TO `grafana`;
GRANT SELECT ON `vn`.`creditClassification` TO `grafana`;
GRANT SELECT ON `vn`.`ticketLog` TO `grafana`;
GRANT SELECT ON `srt`.`moving` TO `grafana`;
GRANT SELECT ON `vn`.`claimDevelopment` TO `grafana`;
GRANT SELECT ON `srt`.`expeditionLog` TO `grafana`;
GRANT SELECT ON `bs`.`compradores_evolution` TO `grafana`;
GRANT SELECT ON `vn`.`currency` TO `grafana`;
GRANT SELECT ON `vn`.`claimObservation` TO `grafana`;
GRANT SELECT ON `vn`.`salesPreviousPreparated` TO `grafana`;
GRANT SELECT ON `vn`.`claimState` TO `grafana`;
GRANT SELECT ON `vn`.`company` TO `grafana`;
GRANT SELECT ON `srt`.`buffer` TO `grafana`;
GRANT SELECT ON `vn`.`greuge` TO `grafana`;
GRANT SELECT ON `vn`.`routeComplement` TO `grafana`;
GRANT SELECT ON `vn`.`saleVolume` TO `grafana`;
GRANT SELECT ON `vn`.`component` TO `grafana`;
GRANT SELECT ON `vn`.`train` TO `grafana`;
GRANT SELECT ON `srt`.`ticketPalletized` TO `grafana`;
GRANT SELECT ON `vn`.`autonomy` TO `grafana`;
GRANT SELECT ON `vn`.`expeditionMistakeType` TO `grafana`;
GRANT SELECT ON `vn`.`ticketParking` TO `grafana`;
GRANT SELECT ON `vn`.`itemShelving` TO `grafana`;
GRANT SELECT ON `vn`.`state` TO `grafana`;
GRANT SELECT ON `vn`.`taxClass` TO `grafana`;
GRANT SELECT ON `bs`.`salesByWeek` TO `grafana`;
GRANT SELECT ON `vn`.`invoiceInDueDay` TO `grafana`;
GRANT SELECT ON `vn`.`sectorProductivity` TO `grafana`;
GRANT SELECT ON `bs`.`salesByclientSalesPerson` TO `grafana`;
GRANT SELECT ON `edi`.`marketPlace` TO `grafana`;
GRANT SELECT ON `vn`.`routeAction` TO `grafana`;
GRANT SELECT ON `vn`.`deviceProduction` TO `grafana`;
GRANT SELECT ON `vn`.`invoiceOut` TO `grafana`;
GRANT SELECT ON `vn`.`printer` TO `grafana`;
GRANT SELECT ON `vn`.`mdbBranch` TO `grafana`;
GRANT SELECT ON `bs`.`workerProductivity` TO `grafana`;
GRANT SELECT ON `vn`.`config` TO `grafana`;
GRANT SELECT ON `hedera`.`userSession` TO `grafana`;
GRANT SELECT ON `vn`.`receipt` TO `grafana`;
GRANT SELECT ON `vn`.`buy` TO `grafana`;
GRANT SELECT ON `vn`.`calendarHolidays` TO `grafana`;
GRANT SELECT ON `vn`.`parking` TO `grafana`;
GRANT SELECT ON `vn`.`role` TO `grafana`;
GRANT SELECT ON `vn`.`errorLogApp` TO `grafana`;
GRANT SELECT ON `vn`.`continent` TO `grafana`;
GRANT SELECT ON `srt`.`lastRFID` TO `grafana`;
GRANT SELECT ON `vn`.`farmingInvoiceIn` TO `grafana`;
GRANT SELECT ON `vn`.`agencyMode` TO `grafana`;
GRANT SELECT ON `vn`.`absenceType` TO `grafana`;
GRANT SELECT ON `vn`.`saleGroupDetail` TO `grafana`;
GRANT SELECT ON `vn`.`workerMistakeType` TO `grafana`;
GRANT SELECT ON `vn`.`mdbVersionTree` TO `grafana`;
GRANT SELECT ON `vn`.`expeditionTruck` TO `grafana`;
GRANT SELECT ON `vn`.`routeConfig` TO `grafana`;
GRANT SELECT ON `vn`.`claimReason` TO `grafana`;
GRANT SELECT ON `edi`.`log` TO `grafana`;
GRANT SELECT ON `srt`.`failureLog` TO `grafana`;
GRANT SELECT ON `bs`.`clientNewBorn` TO `grafana`;
GRANT SELECT ON `vn`.`farming` TO `grafana`;
GRANT SELECT ON `hedera`.`order` TO `grafana`;
GRANT SELECT ON `bs`.`packingSpeed` TO `grafana`;
GRANT SELECT ON `vn`.`expense` TO `grafana`;
GRANT SELECT ON `vn`.`workerLabour` TO `grafana`;
GRANT SELECT ON `hedera`.`orderRow` TO `grafana`;
GRANT SELECT ON `srt`.`movingLog` TO `grafana`;
GRANT SELECT ON `vn`.`warehouse` TO `grafana`;
GRANT SELECT ON `vn`.`sector` TO `grafana`;
GRANT SELECT ON `vn`.`salesPersonGoal` TO `grafana`;
GRANT SELECT ON `srt`.`movingState` TO `grafana`;
GRANT SELECT ON `vn`.`claimResult` TO `grafana`;
GRANT SELECT ON `vn`.`routesMonitor` TO `grafana`;
GRANT SELECT ON `vn`.`expeditionPallet` TO `grafana`;
GRANT SELECT ON `bs`.`ventas` TO `grafana`;
GRANT SELECT ON `vn`.`intrastat` TO `grafana`;
GRANT SELECT ON `vn`.`printQueueArgs` TO `grafana`;
GRANT SELECT ON `bi`.`Greuge_Evolution` TO `grafana`;
GRANT SELECT ON `vn`.`host` TO `grafana`;
GRANT SELECT ON `vn`.`country` TO `grafana`;
GRANT SELECT ON `bs`.`waste` TO `grafana`;
GRANT SELECT ON `vn`.`ticketTracking` TO `grafana`;
GRANT SELECT ON `vn`.`itemCategory` TO `grafana`;
GRANT SELECT ON `vn`.`saleTracking` TO `grafana`;
GRANT SELECT ON `vn`.`producer` TO `grafana`;
GRANT SELECT ON `cache`.`stock` TO `grafana`;
GRANT SELECT (name, active, role, email, id, nickname) ON `account`.`user` TO `grafana`;
GRANT SELECT ON `vn`.`deliveryMethod` TO `grafana`;
GRANT SELECT ON `vn`.`ticketCollection` TO `grafana`;
GRANT EXECUTE ON PROCEDURE `vn`.`zone_upcomingdeliveries` TO `grafana`;
GRANT EXECUTE ON PROCEDURE `vn`.`zone_getaddresses` TO `grafana`;
GRANT EXECUTE ON FUNCTION `util`.`firstdayofmonth` TO `grafana`;
GRANT EXECUTE ON FUNCTION `util`.`dayend` TO `grafana`;
GRANT EXECUTE ON FUNCTION `vn`.`lastdayofweek` TO `grafana`;
GRANT EXECUTE ON FUNCTION `vn`.`firstdayofweek` TO `grafana`;
GRANT EXECUTE ON FUNCTION `util`.`quarterfirstday` TO `grafana`;
GRANT EXECUTE ON FUNCTION `util`.`firstdayofyear` TO `grafana`;

FLUSH PRIVILEGES;
