Local database structure updated & import changes script
This commit is contained in:
parent
98b26a3c27
commit
4876f36190
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
myDir=$(dirname $0)
|
||||||
|
|
||||||
|
for file in $myDir/changes/*/*.sql; do
|
||||||
|
echo "Importing $file"
|
||||||
|
mysql -u root < $file
|
||||||
|
done
|
|
@ -272,14 +272,14 @@ INSERT INTO `account`.`user`(`id`,`name`,`password`,`role`,`active`,`email`)
|
||||||
(10, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 9, 1, 'JessicaJones@verdnatura.es'),
|
(10, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 9, 1, 'JessicaJones@verdnatura.es'),
|
||||||
(11, 'Cyborg', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'cyborg@verdnatura.es');
|
(11, 'Cyborg', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'cyborg@verdnatura.es');
|
||||||
|
|
||||||
INSERT INTO `salix`.`Country`(`id`, `name`, `inCee`, `code`, `currencyFk`, `realCountryFk`)
|
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'España', 0, 'ES', 1, 1),
|
(1, 'España', 0, 'ES', 1),
|
||||||
(2, 'Italia', 1, 'IT', 1, 2),
|
(2, 'Italia', 1, 'IT', 1),
|
||||||
(3, 'Alemania', 1, 'DE', 1, 3),
|
(3, 'Alemania', 1, 'DE', 1),
|
||||||
(4, 'Rumania', 1, 'RO', 1, 4),
|
(4, 'Rumania', 1, 'RO', 1),
|
||||||
(5, 'Holanda', 1, 'NL', 1, 5),
|
(5, 'Holanda', 1, 'NL', 1),
|
||||||
(30,'Francia', 1, 'FR', 1, 6);
|
(30,'Francia', 1, 'FR', 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `isManaged`)
|
INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `isManaged`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -305,7 +305,7 @@ INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`)
|
||||||
VALUES
|
VALUES
|
||||||
(8, 'Pay on receipt', '0000000000', 4, 0, 1);
|
(8, 'Pay on receipt', '0000000000', 4, 0, 1);
|
||||||
|
|
||||||
INSERT INTO `salix`.`Agency`(`id`, `name`, `warehouseFk`, `isVolumetric`, `bankFk`, `warehouseAliasFk`)
|
INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `isVolumetric`, `bankFk`, `warehouseAliasFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'inhouse pickup', 1, 0, 8, 1),
|
(1, 'inhouse pickup', 1, 0, 8, 1),
|
||||||
(2, 'Super-Man delivery', 1, 0, 8, 1),
|
(2, 'Super-Man delivery', 1, 0, 8, 1),
|
||||||
|
@ -329,12 +329,6 @@ INSERT INTO `vn`.`payMethod`(`id`, `name`, `graceDays`, `outstandingDebt`, `iban
|
||||||
(4, 'PayMethod with IBAN', 0, 001, 1),
|
(4, 'PayMethod with IBAN', 0, 001, 1),
|
||||||
(5, 'PayMethod five', 10, 001, 0);
|
(5, 'PayMethod five', 10, 001, 0);
|
||||||
|
|
||||||
INSERT INTO `salix`.`Zone`(`id`, `name`, `printingOrder`)
|
|
||||||
VALUES
|
|
||||||
(1, 'zone one', 1),
|
|
||||||
(2, 'zone two', 2),
|
|
||||||
(3, 'zone three', 3);
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `warehouseFk`, `zoneFk`)
|
INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `warehouseFk`, `zoneFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Province one', 1, NULL, 1),
|
(1, 'Province one', 1, NULL, 1),
|
||||||
|
@ -388,7 +382,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
|
||||||
(9, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1),
|
(9, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1),
|
||||||
(10, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1);
|
(10, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1);
|
||||||
|
|
||||||
INSERT INTO `salix`.`Address`(`id`, `consignee`, `street`, `city`, `postcode`, `provinceFk`, `phone`, `mobile`, `isEnabled`, `isDefaultAddress`, `clientFk`, `defaultAgencyFk`, `longitude`, `latitude`, `isEqualizated`)
|
INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isEnabled`, `isDefaultAddress`, `clientFk`, `agencyFk`, `longitude`, `latitude`, `isEqualizated`)
|
||||||
VALUES
|
VALUES
|
||||||
(101, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0),
|
(101, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0),
|
||||||
(102, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0),
|
(102, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0),
|
||||||
|
@ -399,9 +393,9 @@ INSERT INTO `salix`.`Address`(`id`, `consignee`, `street`, `city`, `postcode`, `
|
||||||
(107, 'Hank Pym', 'Your pocket', 'Silla', 46460, 1, NULL, NULL, 1, 1, 7, 2, NULL, NULL, 0),
|
(107, 'Hank Pym', 'Your pocket', 'Silla', 46460, 1, NULL, NULL, 1, 1, 7, 2, NULL, NULL, 0),
|
||||||
(108, 'Charles Xavier', 'Cerebro', 'Silla', 46460, 1, NULL, NULL, 1, 1, 8, 2, NULL, NULL, 0),
|
(108, 'Charles Xavier', 'Cerebro', 'Silla', 46460, 1, NULL, NULL, 1, 1, 8, 2, NULL, NULL, 0),
|
||||||
(109, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0),
|
(109, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0),
|
||||||
(1010,'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0);
|
(110,'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0);
|
||||||
|
|
||||||
INSERT INTO `salix`.`ClientCredit`(`id`, `clientFk`, `employeeFk`, `amount`, `created`)
|
INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, 1200, CURDATE()),
|
(1, 1, 1, 1200, CURDATE()),
|
||||||
(2, 2, 2, 800, CURDATE()),
|
(2, 2, 2, 800, CURDATE()),
|
||||||
|
@ -409,13 +403,13 @@ INSERT INTO `salix`.`ClientCredit`(`id`, `clientFk`, `employeeFk`, `amount`, `cr
|
||||||
(4, 4, 4, 90, CURDATE()),
|
(4, 4, 4, 90, CURDATE()),
|
||||||
(5, 5, 5, 90, CURDATE());
|
(5, 5, 5, 90, CURDATE());
|
||||||
|
|
||||||
INSERT INTO `salix`.`ClientCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1000, 5),
|
(1, 1000, 5),
|
||||||
(2, 600, 5),
|
(2, 600, 5),
|
||||||
(3, 0, 5);
|
(3, 0, 5);
|
||||||
|
|
||||||
INSERT INTO `salix`.`ClientObservation`(`id`, `clientFk`, `employeeFk`, `text`, `created`)
|
INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()),
|
(1, 1, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()),
|
||||||
(2, 2, 1, 'With great power, comes great responsibility', CURDATE()),
|
(2, 2, 1, 'With great power, comes great responsibility', CURDATE()),
|
||||||
|
@ -448,7 +442,7 @@ INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`)
|
||||||
(4, 4, CURDATE(), CURDATE()),
|
(4, 4, CURDATE(), CURDATE()),
|
||||||
(5, 5, CURDATE(), CURDATE());
|
(5, 5, CURDATE(), CURDATE());
|
||||||
|
|
||||||
INSERT INTO `salix`.`Route`(`id`, `date`)
|
INSERT INTO `vn`.`route`(`id`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, CURDATE()),
|
(1, CURDATE()),
|
||||||
(2, CURDATE()),
|
(2, CURDATE()),
|
||||||
|
@ -458,7 +452,7 @@ INSERT INTO `salix`.`Route`(`id`, `date`)
|
||||||
(6, CURDATE()),
|
(6, CURDATE()),
|
||||||
(7, CURDATE());
|
(7, CURDATE());
|
||||||
|
|
||||||
INSERT INTO `salix`.`State`(`id`, `name`, `order`, `alertLevel`, `code`)
|
INSERT INTO `vn`.`state`(`id`, `name`, `order`, `alertLevel`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'To check', 2, 0, 'FIXING'),
|
(1, 'To check', 2, 0, 'FIXING'),
|
||||||
(2, 'Owes', 1, 0, 'FREE'),
|
(2, 'Owes', 1, 0, 'FREE'),
|
||||||
|
@ -475,16 +469,16 @@ INSERT INTO `vn2008`.`empresa`(`id`, `abbreviation`, `registro`, `gerente_id`, `
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `clientFk`,`nickname`, `addressFk`)
|
INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `clientFk`,`nickname`, `addressFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, NULL, CURDATE(), 1, 'Batman', 1),
|
(1, 1, 1, NULL, CURDATE(), 1, 'Batman', 101),
|
||||||
(2, 1, 1, NULL, CURDATE(), 1, 'Spider-Man', 2),
|
(2, 1, 1, NULL, CURDATE(), 1, 'Spider-Man', 102),
|
||||||
(3, 2, 2, NULL, CURDATE(), 2, 'Super-Man', 3),
|
(3, 2, 2, NULL, CURDATE(), 2, 'Super-Man', 103),
|
||||||
(4, 2, 2, NULL, CURDATE(), 2, 'Iron-Man', 4),
|
(4, 2, 2, NULL, CURDATE(), 2, 'Iron-Man', 104),
|
||||||
(5, 3, 3, NULL, CURDATE(), 3, 'Magneto', 5),
|
(5, 3, 3, NULL, CURDATE(), 3, 'Magneto', 105),
|
||||||
(6, 3, 3, NULL, CURDATE(), 3, 'Legion', 6),
|
(6, 3, 3, NULL, CURDATE(), 3, 'Legion', 106),
|
||||||
(7, 4, 4, NULL, CURDATE(), 4, 'Ant-Man', 7),
|
(7, 4, 4, NULL, CURDATE(), 4, 'Ant-Man', 107),
|
||||||
(8, 4, 4, NULL, CURDATE(), 4, 'Professor X', 8),
|
(8, 4, 4, NULL, CURDATE(), 4, 'Professor X', 108),
|
||||||
(9, 5, 5, NULL, CURDATE(), 5, 'Hulk', 9),
|
(9, 5, 5, NULL, CURDATE(), 5, 'Hulk', 109),
|
||||||
(10, 6, 5, NULL, CURDATE(), 5, 'Jessica Jones', 10);
|
(10, 6, 5, NULL, CURDATE(), 5, 'Jessica Jones', 110);
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `created`)
|
INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `created`)
|
||||||
VALUES
|
VALUES
|
|
@ -3,9 +3,11 @@ FROM mysql:5.6.37
|
||||||
ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
|
ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
|
||||||
ENV TZ GMT-1
|
ENV TZ GMT-1
|
||||||
|
|
||||||
COPY *.sql /docker-entrypoint-initdb.d/
|
WORKDIR /docker-entrypoint-initdb.d
|
||||||
|
COPY *.sql ./
|
||||||
RUN chmod -R 755 /docker-entrypoint-initdb.d
|
COPY 02-changes.sh .
|
||||||
|
COPY changes changes
|
||||||
|
RUN chmod -R 755 .
|
||||||
|
|
||||||
CMD ["mysqld"]
|
CMD ["mysqld"]
|
||||||
|
|
||||||
|
|
|
@ -8,17 +8,12 @@ VIEW `vn`.`agencyMode` AS
|
||||||
`a`.`Agencia` AS `name`,
|
`a`.`Agencia` AS `name`,
|
||||||
`a`.`description` AS `description`,
|
`a`.`description` AS `description`,
|
||||||
`a`.`Vista` AS `deliveryMethodFk`,
|
`a`.`Vista` AS `deliveryMethodFk`,
|
||||||
`a`.`Vista` AS `__deliveryMethod`,
|
|
||||||
`a`.`Vista` AS `__view`,
|
|
||||||
`a`.`m3` AS `m3`,
|
`a`.`m3` AS `m3`,
|
||||||
`a`.`cod71` AS `cod71`,
|
`a`.`cod71` AS `cod71`,
|
||||||
`a`.`web` AS `web`,
|
`a`.`web` AS `web`,
|
||||||
`a`.`agency_id` AS `agencyFk`,
|
`a`.`agency_id` AS `agencyFk`,
|
||||||
`a`.`agency_id` AS `__agency`,
|
|
||||||
`a`.`agency_service_id` AS `agencyServiceFk`,
|
`a`.`agency_service_id` AS `agencyServiceFk`,
|
||||||
`a`.`agency_service_id` AS `__agencyService`,
|
|
||||||
`a`.`inflacion` AS `inflation`,
|
`a`.`inflacion` AS `inflation`,
|
||||||
`a`.`inflacion` AS `__inflacion`,
|
|
||||||
`a`.`is_volumetric` AS `isVolumetric`,
|
`a`.`is_volumetric` AS `isVolumetric`,
|
||||||
`a`.`send_mail` AS `reportMail`
|
`a`.`send_mail` AS `reportMail`
|
||||||
FROM
|
FROM
|
||||||
|
|
|
@ -6,12 +6,9 @@ VIEW `vn`.`agencyHour` AS
|
||||||
SELECT
|
SELECT
|
||||||
`h`.`agency_hour_id` AS `id`,
|
`h`.`agency_hour_id` AS `id`,
|
||||||
`h`.`agency_id` AS `agencyFk`,
|
`h`.`agency_id` AS `agencyFk`,
|
||||||
`h`.`agency_id` AS `__agency`,
|
|
||||||
`h`.`week_day` AS `weekDay`,
|
`h`.`week_day` AS `weekDay`,
|
||||||
`h`.`warehouse_id` AS `warehouseFk`,
|
`h`.`warehouse_id` AS `warehouseFk`,
|
||||||
`h`.`warehouse_id` AS `__warehouse`,
|
|
||||||
`h`.`province_id` AS `provinceFk`,
|
`h`.`province_id` AS `provinceFk`,
|
||||||
`h`.`province_id` AS `__province`,
|
|
||||||
`h`.`subtract_day` AS `substractDay`,
|
`h`.`subtract_day` AS `substractDay`,
|
||||||
`h`.`max_hour` AS `maxHour`
|
`h`.`max_hour` AS `maxHour`
|
||||||
FROM
|
FROM
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
USE `account`;
|
|
||||||
CREATE
|
|
||||||
OR REPLACE ALGORITHM = UNDEFINED
|
|
||||||
DEFINER = `root`@`%`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `account`.`__userRole` AS
|
|
||||||
SELECT
|
|
||||||
`r`.`inheritsFrom` AS `id`
|
|
||||||
FROM
|
|
||||||
(`account`.`roleRole` `r`
|
|
||||||
JOIN `account`.`user` `u` ON ((`u`.`role` = `r`.`role`)))
|
|
||||||
WHERE
|
|
||||||
(`u`.`id` = USERGETID());
|
|
||||||
|
|
||||||
DROP VIEW `account`.`userRole`;
|
|
||||||
|
|
||||||
CREATE TABLE `account`.`userRole` (
|
|
||||||
`userFk` INT(10) UNSIGNED NOT NULL,
|
|
||||||
`roleFk` INT(10) UNSIGNED NOT NULL,
|
|
||||||
PRIMARY KEY (`userFk`, `roleFk`));
|
|
||||||
|
|
||||||
ALTER TABLE `account`.`userRole`
|
|
||||||
ADD INDEX `user` (`userFk` ASC),
|
|
||||||
ADD INDEX `role` (`roleFk` ASC);
|
|
||||||
|
|
||||||
ALTER TABLE `account`.`userRole`
|
|
||||||
ADD CONSTRAINT `user`
|
|
||||||
FOREIGN KEY (`userFk`)
|
|
||||||
REFERENCES `account`.`user` (`id`)
|
|
||||||
ON DELETE CASCADE
|
|
||||||
ON UPDATE CASCADE,
|
|
||||||
ADD CONSTRAINT `role`
|
|
||||||
FOREIGN KEY (`roleFk`)
|
|
||||||
REFERENCES `account`.`role` (`id`)
|
|
||||||
ON DELETE CASCADE
|
|
||||||
ON UPDATE CASCADE;
|
|
|
@ -1,31 +0,0 @@
|
||||||
DROP function IF EXISTS `userHasRoleId`;
|
|
||||||
DELIMITER $$
|
|
||||||
CREATE DEFINER=`root`@`%` FUNCTION `account`.`userHasRoleId`(vRoleId INT) RETURNS tinyint(1)
|
|
||||||
DETERMINISTIC
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Comprueba si el usuario actual tiene asociado un rol.
|
|
||||||
*
|
|
||||||
* @param vRoleId Identificador del rol a comprobar
|
|
||||||
* @return %TRUE si tiene el rol, %FALSE en caso contrario
|
|
||||||
*/
|
|
||||||
DECLARE vHasRole BOOL DEFAULT FALSE;
|
|
||||||
|
|
||||||
SELECT COUNT(*) > 0 INTO vHasRole
|
|
||||||
FROM user u
|
|
||||||
JOIN roleRole r ON r.role = u.role
|
|
||||||
WHERE u.id = userGetId()
|
|
||||||
AND r.inheritsFrom = vRoleId;
|
|
||||||
|
|
||||||
IF NOT vHasRole
|
|
||||||
THEN
|
|
||||||
SELECT COUNT(*) > 0 INTO vHasRole
|
|
||||||
FROM userRole
|
|
||||||
WHERE userFk = userGetId()
|
|
||||||
AND roleFk = vRoleId;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
RETURN vHasRole;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
||||||
|
|
Loading…
Reference in New Issue