diff --git a/db/changes/232601/00-client_create.sql b/db/changes/232601/00-client_create.sql index 9e2c55c40..e43eb7b38 100644 --- a/db/changes/232601/00-client_create.sql +++ b/db/changes/232601/00-client_create.sql @@ -36,19 +36,19 @@ BEGIN DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; - SELECT payMethodFk, - dueDay, - credit, - isTaxDataChecked, - hasCoreVnl, - mandateTypeFk + SELECT dafaultPayMethodFk, + defaultDueDay, + defaultCredit, + defaultIsTaxDataChecked, + defaultHasCoreVnl, + defaultMandateTypeFk INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, vMandateTypeFk - FROM clientNewConfig; + FROM clientConfig; INSERT INTO `client` SET id = vUserFk, @@ -78,7 +78,7 @@ BEGIN INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) SELECT vUserFk, vCompanyFk, vMandateTypeFk WHERE NOT EXISTS ( - SELECT 1 + SELECT id FROM mandate WHERE clientFk = vUserFk AND companyFk = vCompanyFk @@ -87,27 +87,19 @@ BEGIN END$$ DELIMITER ; -CREATE TABLE IF NOT EXISTS vn.clientNewConfig ( - id int unsigned auto_increment NULL, - payMethodFk tinyint(3) unsigned NULL, - dueDay int unsigned NULL, - credit decimal(10, 2) NULL, - isTaxDataChecked tinyint(1) NULL, - hasCoreVnl boolean NULL, - mandateTypeFk smallint(5) NULL, - CONSTRAINT clientNewConfig_PK PRIMARY KEY (id), - CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (payMethodFk) REFERENCES vn.payMethod(id), - CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (mandateTypeFk) REFERENCES vn.mandateType(id) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; +ALTER TABLE vn.clientConfig ADD dafaultPayMethodFk tinyint(3) unsigned NULL; +ALTER TABLE vn.clientConfig ADD defaultDueDay int unsigned NULL; +ALTER TABLE vn.clientConfig ADD defaultCredit decimal(10, 2) NULL; +ALTER TABLE vn.clientConfig ADD defaultIsTaxDataChecked tinyint(1) NULL; +ALTER TABLE vn.clientConfig ADD defaultHasCoreVnl boolean NULL; +ALTER TABLE vn.clientConfig ADD defaultMandateTypeFk smallint(5) NULL; +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (dafaultPayMethodFk) REFERENCES vn.payMethod(id); +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (defaultMandateTypeFk) REFERENCES vn.mandateType(id); -INSERT IGNORE INTO vn.clientNewConfig - SET id = 1, - payMethodFk = 4, - dueDay = 5, - credit = 300.0, - isTaxDataChecked = 1, - hasCoreVnl = 1, - mandateTypeFk = 2; \ No newline at end of file +UPDATE vn.clientConfig + SET dafaultPayMethodFk = 4, + defaultDueDay = 5, + defaultCredit = 300.0, + defaultIsTaxDataChecked = 1, + defaultHasCoreVnl = 1, + defaultMandateTypeFk = 2; \ No newline at end of file