USE `postgresql`;

DELIMITER $$

USE `postgresql`$$
DROP TRIGGER IF EXISTS `postgresql`.`income_employee_afterInsert` $$
DELIMITER ;
USE `postgresql`;

DELIMITER $$

USE `postgresql`$$
DROP TRIGGER IF EXISTS `postgresql`.`income_employee_afterUpdate` $$
DELIMITER ;
USE `postgresql`;

DELIMITER $$

USE `postgresql`$$
DROP TRIGGER IF EXISTS `postgresql`.`income_employee_afterDelete` $$
DELIMITER ;

ALTER TABLE `postgresql`.`income_employee` RENAME `vn`.`workerIncome`;

ALTER TABLE `vn`.`workerIncome`
CHANGE COLUMN `debe` `debit` decimal(10,2) NOT NULL DEFAULT 0.00,
CHANGE COLUMN `haber` `credit` decimal(10,2) NOT NULL DEFAULT 0.00,
CHANGE COLUMN `id_incomeType` `incomeTypeFk` int(11) DEFAULT NULL,
CHANGE COLUMN `odbc_date` `paymentDate` date DEFAULT NULL,
CHANGE COLUMN `concepto` `concept` longtext DEFAULT NULL;

GRANT SELECT ON TABLE `vn`.`workerIncome` TO `hr`;
GRANT INSERT, UPDATE, DELETE ON TABLE `vn`.`workerIncome` TO `hrBoss`;