salix/db/versions/10836-limeCordyline/03-gastos_resumen.sql

18 lines
984 B
SQL

ALTER TABLE IF EXISTS `vn2008`.`gastos_resumen` RENAME `vn`.`expenseSummary`;
ALTER TABLE IF EXISTS `vn`.`expenseSummary`
CHANGE COLUMN IF EXISTS `Id_Gasto` `expenseFk` varchar(10) NOT NULL,
CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) DEFAULT NULL,
CHANGE COLUMN IF EXISTS `empresa_id` `companyFk` int(11) NOT NULL;
ALTER TABLE IF EXISTS vn.expenseSummary COLLATE=utf8mb3_general_ci;
ALTER TABLE IF EXISTS vn.expenseSummary MODIFY COLUMN expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
ALTER TABLE IF EXISTS vn.expenseSummary ADD CONSTRAINT expenseSummary_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE IF EXISTS vn.expenseSummary MODIFY COLUMN companyFk int(10) unsigned NOT NULL;
ALTER TABLE IF EXISTS vn.expenseSummary ADD CONSTRAINT expenseSummary_company_FK FOREIGN KEY (companyFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE;