Merge pull request 'fix: refs #6371 balanceNestTree add constraint' (!2039) from 6371-fixCreateConstraint into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2039 Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
This commit is contained in:
commit
e21f8aafe0
|
@ -6,9 +6,11 @@ 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;
|
||||
|
||||
UPDATE vn.balanceNestTree
|
||||
SET expenseFk = NULL
|
||||
WHERE expenseFk ='';
|
||||
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);
|
||||
|
||||
ALTER TABLE IF EXISTS vn.balanceNestTree ADD CONSTRAINT balanceNestTree_expense_FK
|
||||
FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
Loading…
Reference in New Issue