refactor: refs #8573 update before alter table
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Ivan Mas 2025-02-13 16:41:29 +01:00
parent f12c47cdf8
commit caa921020d
2 changed files with 18 additions and 9 deletions

View File

@ -1,9 +1,9 @@
ALTER TABLE vn.expedition
MODIFY COLUMN hostFk VARCHAR(30) COLLATE utf8mb3_general_ci;
ALTER TABLE vn.expedition
ADD CONSTRAINT fk_expedition_host_code
FOREIGN KEY (hostFk)
REFERENCES host(code)
ON UPDATE CASCADE
ON DELETE CASCADE;
UPDATE vn.expedition e
JOIN (
SELECT id
FROM vn.expedition
WHERE hostFk COLLATE utf8mb3_unicode_ci NOT IN
(SELECT code COLLATE utf8mb3_unicode_ci FROM host WHERE code IS NOT NULL)
) s
ON e.id = s.id
SET e.hostFk = 'pc336';

View File

@ -0,0 +1,9 @@
ALTER TABLE vn.expedition
MODIFY COLUMN hostFk VARCHAR(30) COLLATE utf8mb3_general_ci;
ALTER TABLE vn.expedition
ADD CONSTRAINT fk_expedition_host_code
FOREIGN KEY (hostFk)
REFERENCES host(code)
ON UPDATE CASCADE
ON DELETE CASCADE;