Logiciel Pastèque/API/DB Fix for 8-alpha
SQL fix for API 8.0 before alpha 6
modifierAPI 8.0 alpha 1 to 5 have an error in the model declaration for Customer which implies a missing field in database. While the update requires to run an sql script, the barcode field from products has also been fixed to be not nullable, with the default empty string value from code for consistency with all the other string fields.
To update from any of those versions to alpha 6 or later, please update all the existing databases with the following scripts. Any database initialized with alpha 6 or later already includes these fixes.
For Postgresql:
-- Postgresql fix ALTER TABLE customers ADD tariffarea_id INT DEFAULT NULL; ALTER TABLE customers ADD CONSTRAINT FK_62534E2154EC7A8F FOREIGN KEY (tariffarea_id) REFERENCES tariffareas (id) NOT DEFERRABLE INITIALLY IMMEDIATE; CREATE INDEX IDX_62534E2154EC7A8F ON customers (tariffarea_id); UPDATE products set barcode = '' where barcode is null; ALTER TABLE products ALTER barcode SET NOT NULL;
For Mysql/MariaDB:
-- Mysql fix ALTER TABLE customers ADD tariffarea_id INT DEFAULT NULL; ALTER TABLE customers ADD CONSTRAINT FK_62534E2154EC7A8F FOREIGN KEY (tariffarea_id) REFERENCES tariffareas (id); CREATE INDEX IDX_62534E2154EC7A8F ON customers (tariffarea_id); UPDATE products SET barcode = '' WHERE barcode IS NULL; ALTER TABLE products CHANGE barcode barcode VARCHAR(255) NOT NULL;