Merge pull request 'refactor: refs #8573 add fk to expedition.hostFk' (!3447) from 8573-addFkExpeditionHost into dev
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
Reviewed-on: #3447 Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
This commit is contained in:
commit
9000becf07
|
@ -0,0 +1,9 @@
|
|||
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';
|
|
@ -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;
|
|
@ -49,7 +49,7 @@ module.exports = Self => {
|
|||
ps.monitorId,
|
||||
e.created
|
||||
FROM expedition e
|
||||
JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk
|
||||
JOIN host h ON h.code = e.hostFk
|
||||
JOIN packingSite ps ON ps.hostFk = h.id
|
||||
WHERE e.id = ?;`;
|
||||
const [expedition] = await models.Expedition.rawSql(query, [id]);
|
||||
|
|
|
@ -44,7 +44,7 @@ module.exports = Self => {
|
|||
ps.monitorId,
|
||||
e.created
|
||||
FROM expedition e
|
||||
JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk
|
||||
JOIN host h ON h.code = e.hostFk
|
||||
JOIN packingSite ps ON ps.hostFk = h.id
|
||||
WHERE e.id = ?;`;
|
||||
|
||||
|
|
Loading…
Reference in New Issue