2024-01-29 11:35:49 +00:00
|
|
|
ALTER TABLE IF EXISTS `vn2008`.`balance_nest_tree` RENAME `vn`.`balanceNestTree`;
|
|
|
|
|
|
|
|
ALTER TABLE IF EXISTS `vn`.`balanceNestTree`
|
|
|
|
CHANGE COLUMN IF EXISTS `Id_Gasto` `expenseFk` varchar(10) DEFAULT NULL;
|
|
|
|
|
|
|
|
ALTER TABLE vn.balanceNestTree
|
|
|
|
MODIFY COLUMN IF EXISTS expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;
|
|
|
|
|
2024-02-14 13:42:04 +00:00
|
|
|
UPDATE vn.balanceNestTree b
|
|
|
|
LEFT JOIN vn.expense e ON e.id = b.expenseFk COLLATE utf8mb3_general_ci
|
|
|
|
SET b.expenseFk = NULL
|
|
|
|
WHERE b.expenseFk =''
|
|
|
|
OR (e.id IS NULL AND b.expenseFk IS NOT NULL);
|
2024-01-29 11:35:49 +00:00
|
|
|
|
|
|
|
ALTER TABLE IF EXISTS vn.balanceNestTree ADD CONSTRAINT balanceNestTree_expense_FK
|
|
|
|
FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
|