From 7200aa3dfc2762a93668c86487a492bb7fa7b281 Mon Sep 17 00:00:00 2001 From: bernat Date: Fri, 30 Oct 2020 10:23:42 +0100 Subject: [PATCH] fixtures and sql for supplierContact --- .../10240-allSaints/00-supplier_contact.sql | 24 +++++++++++++++++++ db/dump/fixtures.sql | 7 ++++++ 2 files changed, 31 insertions(+) create mode 100644 db/changes/10240-allSaints/00-supplier_contact.sql diff --git a/db/changes/10240-allSaints/00-supplier_contact.sql b/db/changes/10240-allSaints/00-supplier_contact.sql new file mode 100644 index 000000000..5054366b0 --- /dev/null +++ b/db/changes/10240-allSaints/00-supplier_contact.sql @@ -0,0 +1,24 @@ +CREATE TABLE `vn`.`supplierContact` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `supplierFk` INT(11) NULL DEFAULT NULL, + `phone` VARCHAR(16) NULL DEFAULT NULL, + `mobile` VARCHAR(16) NULL DEFAULT NULL, + `email` VARCHAR(255) NULL DEFAULT NULL, + `observation` TEXT NULL DEFAULT NULL, + `name` VARCHAR(255) NULL DEFAULT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +ALTER TABLE `vn`.`supplierContact` +ADD CONSTRAINT `supplier_id` + FOREIGN KEY (`supplierFk`) + REFERENCES `vn`.`supplier` (`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO vn.supplierContact(supplierFk,phone,mobile,email,observation,`name`) + SELECT r.Id_Proveedor,c.Telefono,c.Movil,c.email,c.Notas,concat(c.Nombre," ", IFNULL(c.Apellidos,"")) + FROM vn2008.Contactos c + JOIN vn2008.Relaciones r ON r.Id_Contacto = c.Id_Contacto + JOIN vn.supplier s ON s.id = r.Id_Proveedor; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index cc3f2f689..0ca1a8820 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1214,6 +1214,13 @@ INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif` (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2, 10), (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15); +INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) + VALUES + (1, 1, 123121212, 654789123, 'supplier1@email.es', 'observation1', 'the boss'), + (2, 1, 987456132, NULL, NULL, NULL, 'the salesperson'), + (3, 2, 321654987, NULL, 'supplier2@email.es', NULL, NULL), + (4, 442, 321654987, NULL, NULL, 'observation442', NULL); + INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES (1, 2, 'available', CONCAT_WS('/',1,CURDATE()), CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE), CURDATE(), NULL),