salix/db/changes/230801/00-supplierIsVies.sql

17 lines
671 B
SQL

ALTER TABLE `vn`.`supplier` ADD `isVies` tinyint(4) DEFAULT 0 NOT NULL;
UPDATE `vn`.`supplier` s
JOIN vn.country c ON c.id = s.countryFk
SET s.nif = MID(s.nif, 3, LENGTH(s.nif)-1), s.isVies = TRUE
WHERE s.nif <> TRIM(IF(c.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif)-1), s.nif));
INSERT IGNORE INTO `vn`.`chat`
(senderFk, recipient, checkUserStatus, message, status, attempts)
VALUES(19263, '#informatica-cau', 0, '
```
UPDATE `vn`.`supplier` s
JOIN vn.country c ON c.id = s.countryFk
SET s.nif = MID(s.nif, 3, LENGTH(s.nif)-1), s.isVies = TRUE
WHERE s.nif <> TRIM(IF(c.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif)-1), s.nif));
```', 0, 0);