Migration complete & test
This commit is contained in:
parent
304355fb9d
commit
3428dfa6e0
|
@ -1,4 +1,4 @@
|
||||||
FROM mysql:5.6.42
|
FROM mysql:8.0.18
|
||||||
|
|
||||||
ENV MYSQL_ROOT_PASSWORD root
|
ENV MYSQL_ROOT_PASSWORD root
|
||||||
ENV TZ Europe/Madrid
|
ENV TZ Europe/Madrid
|
||||||
|
@ -7,36 +7,33 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends curl ca-certificates \
|
&& apt-get install -y --no-install-recommends curl ca-certificates \
|
||||||
&& curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \
|
&& curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \
|
||||||
&& echo "deb http://apt.verdnatura.es/ jessie main" > /etc/apt/sources.list.d/vn.list \
|
&& echo "deb http://apt.verdnatura.es/ stretch main" > /etc/apt/sources.list.d/vn.list \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install -y --allow-unauthenticated vn-mysql \
|
&& apt-get install -y vn-mysql libmysqlclient21 \
|
||||||
&& apt-get purge -y --auto-remove curl ca-certificates \
|
&& apt-get purge -y --auto-remove curl ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# XXX: Removes the last script line to avoid daemon to be started
|
COPY docker/docker.cnf /etc/mysql/conf.d/
|
||||||
RUN cp /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-init.sh \
|
COPY docker/docker-init.sh docker/docker-start.sh /usr/local/bin/
|
||||||
&& sed -i '$ d' /usr/local/bin/docker-init.sh
|
|
||||||
|
|
||||||
WORKDIR /docker-entrypoint-initdb.d
|
|
||||||
ARG STAMP=unknown
|
|
||||||
|
|
||||||
COPY import-changes.sh config.ini /docker-entrypoint-initdb.d/import/
|
|
||||||
COPY docker.cnf /etc/mysql/mysql.conf.d/
|
|
||||||
COPY changes /docker-entrypoint-initdb.d/import/changes
|
|
||||||
|
|
||||||
COPY docker-boot.sh /docker-entrypoint-initdb.d/
|
|
||||||
COPY dump /docker-entrypoint-initdb.d/dump
|
|
||||||
|
|
||||||
RUN mkdir /mysql-data \
|
RUN mkdir /mysql-data \
|
||||||
&& /usr/local/bin/docker-init.sh mysqld --datadir /mysql-data \
|
&& chown -R mysql:mysql /mysql-data
|
||||||
&& chown -R mysql:mysql /mysql-data \
|
|
||||||
|
WORKDIR /docker-entrypoint-initdb.d
|
||||||
|
|
||||||
|
COPY dump dump
|
||||||
|
COPY docker/docker-boot.sh /docker-entrypoint-initdb.d/
|
||||||
|
COPY changes import/changes
|
||||||
|
COPY import-changes.sh config.ini import/
|
||||||
|
|
||||||
|
ARG STAMP=unknown
|
||||||
|
RUN gosu mysql docker-init.sh mysqld \
|
||||||
&& rm -rf /docker-entrypoint-initdb.d/*
|
&& rm -rf /docker-entrypoint-initdb.d/*
|
||||||
|
|
||||||
COPY docker-start.sh /usr/local/bin/
|
USER mysql
|
||||||
ENTRYPOINT ["docker-start.sh"]
|
ENTRYPOINT ["docker-start.sh"]
|
||||||
|
|
||||||
USER mysql
|
CMD ["mysqld"]
|
||||||
CMD ["mysqld", "--datadir", "/mysql-data"]
|
|
||||||
|
|
||||||
#HEALTHCHECK --interval=5s --timeout=10s --retries=200 \
|
#HEALTHCHECK --interval=5s --timeout=10s --retries=200 \
|
||||||
# CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1
|
# CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1
|
||||||
|
|
|
@ -6,8 +6,8 @@ USE `vn`$$
|
||||||
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
|
CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Devuelve el listado de agencias disponibles para la fecha,
|
* Devuelve el listado de agencias disponibles para la fecha,
|
||||||
* dirección y warehouse pasadas
|
* dirección y almacén pasados.
|
||||||
*
|
*
|
||||||
* @param vAddress
|
* @param vAddress
|
||||||
* @param vWarehouse warehouse
|
* @param vWarehouse warehouse
|
||||||
|
@ -30,7 +30,8 @@ BEGIN
|
||||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||||
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
||||||
WHERE zw.warehouseFk
|
WHERE zw.warehouseFk
|
||||||
GROUP BY z.agencyModeFk;
|
GROUP BY z.agencyModeFk
|
||||||
|
ORDER BY agencyMode;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.zone,
|
tmp.zone,
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[mysqld]
|
|
||||||
innodb_log_file_size = 4M
|
|
||||||
innodb_autoextend_increment = 4
|
|
||||||
innodb_page_size = 8K
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
|
mysql_check_config "$@"
|
||||||
|
docker_setup_env "$@"
|
||||||
|
docker_create_db_directories
|
||||||
|
|
||||||
|
docker_verify_minimum_env
|
||||||
|
docker_init_database_dir "$@"
|
||||||
|
docker_temp_server_start "$@"
|
||||||
|
docker_setup_db
|
||||||
|
|
||||||
|
docker_process_init_files /docker-entrypoint-initdb.d/*
|
||||||
|
|
||||||
|
mysql_expire_root_user
|
||||||
|
docker_temp_server_stop
|
|
@ -0,0 +1,10 @@
|
||||||
|
[mysqld]
|
||||||
|
innodb_log_file_size = 4M
|
||||||
|
innodb_autoextend_increment = 4
|
||||||
|
innodb_page_size = 8K
|
||||||
|
innodb_default_row_format = COMPACT
|
||||||
|
log_bin_trust_function_creators = ON
|
||||||
|
datadir = /mysql-data
|
||||||
|
sql_mode = NO_ENGINE_SUBSTITUTION
|
||||||
|
innodb_temp_data_file_path = /tmp/ibtmp1:12M:autoextend
|
||||||
|
skip-log-bin
|
|
@ -1,10 +1,13 @@
|
||||||
-- FIXME: cuando se eliminen los procedimientos de la cache, se podra eliminar esta linea
|
-- FIXME: cuando se eliminen los procedimientos de la cache, se podra eliminar esta linea
|
||||||
CREATE SCHEMA IF NOT EXISTS `vn2008`;
|
CREATE SCHEMA IF NOT EXISTS `vn2008`;
|
||||||
|
CREATE SCHEMA IF NOT EXISTS `tmp`;
|
||||||
|
|
||||||
|
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
|
||||||
|
|
||||||
ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1;
|
ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1;
|
||||||
ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1;
|
ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1;
|
||||||
ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
|
ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
|
||||||
|
ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1;
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
|
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
-- Import compiled functions
|
-- Import compiled functions
|
||||||
CREATE AGGREGATE FUNCTION minacum RETURNS INT SONAME 'minacum.so';
|
CREATE AGGREGATE FUNCTION minacum RETURNS INT SONAME 'minacum.so';
|
||||||
CREATE AGGREGATE FUNCTION multimax RETURNS INT SONAME 'multimax.so';
|
CREATE AGGREGATE FUNCTION multimax RETURNS INT SONAME 'multimax.so';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
import selectors from '../../helpers/selectors.js';
|
||||||
import createNightmare from '../../helpers/nightmare';
|
import createNightmare from '../../helpers/nightmare';
|
||||||
|
|
||||||
describe('Claim development', () => {
|
fdescribe('Claim development', () => {
|
||||||
const nightmare = createNightmare();
|
const nightmare = createNightmare();
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
@ -116,16 +116,12 @@ describe('Claim development', () => {
|
||||||
const responsible = await nightmare
|
const responsible = await nightmare
|
||||||
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimResponsibleAutocomplete} input`, 'value');
|
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimResponsibleAutocomplete} input`, 'value');
|
||||||
|
|
||||||
const worker = await nightmare
|
|
||||||
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimWorkerAutocomplete} input`, 'value');
|
|
||||||
|
|
||||||
const redelivery = await nightmare
|
const redelivery = await nightmare
|
||||||
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimRedeliveryAutocomplete} input`, 'value');
|
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimRedeliveryAutocomplete} input`, 'value');
|
||||||
|
|
||||||
expect(reason).toEqual('Prisas');
|
expect(reason).toEqual('Prisas');
|
||||||
expect(result).toEqual('Otros daños');
|
expect(result).toEqual('Otros daños');
|
||||||
expect(responsible).toEqual('Compradores');
|
expect(responsible).toEqual('Compradores');
|
||||||
expect(worker).toEqual('managerNick');
|
|
||||||
expect(redelivery).toEqual('Cliente');
|
expect(redelivery).toEqual('Cliente');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
/**
|
/**
|
||||||
* Returns a set of allowed values defined on table scheme
|
* Returns a set of allowed values defined on table scheme
|
||||||
|
@ -7,7 +9,6 @@ module.exports = Self => {
|
||||||
Self.getSetValues = async function(column) {
|
Self.getSetValues = async function(column) {
|
||||||
let model = this.app.models[this.modelName].definition;
|
let model = this.app.models[this.modelName].definition;
|
||||||
let properties = model.properties;
|
let properties = model.properties;
|
||||||
let columnName;
|
|
||||||
let tableName = this.modelName;
|
let tableName = this.modelName;
|
||||||
let schema = null;
|
let schema = null;
|
||||||
|
|
||||||
|
@ -17,35 +18,32 @@ module.exports = Self => {
|
||||||
schema = tableSplit.pop() || null;
|
schema = tableSplit.pop() || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties[column]) {
|
let property = properties[column];
|
||||||
columnName = column;
|
|
||||||
|
|
||||||
if (properties[column].mysql)
|
if (!property)
|
||||||
columnName = properties[column].mysql.columnName;
|
throw new UserError(`Column does not exist`);
|
||||||
}
|
|
||||||
|
|
||||||
let findColumn = Object.keys(properties).find(prop => {
|
let columnName = property.mysql
|
||||||
return properties[prop].mysql && properties[prop].mysql.columnName === column;
|
? property.mysql.columnName
|
||||||
});
|
: column;
|
||||||
|
|
||||||
if (findColumn)
|
let columnInfo = await this.rawSql(
|
||||||
columnName = properties[findColumn].mysql.columnName;
|
`SELECT column_type columnType
|
||||||
|
FROM information_schema.columns
|
||||||
let type = await this.rawSql(
|
|
||||||
`SELECT DISTINCT column_type FROM information_schema.columns
|
|
||||||
WHERE table_name = ?
|
WHERE table_name = ?
|
||||||
AND table_schema = IFNULL(?, DATABASE())
|
AND table_schema = IFNULL(?, DATABASE())
|
||||||
AND column_name = ?`,
|
AND column_name = ?`,
|
||||||
[tableName, schema, columnName]
|
[tableName, schema, columnName]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!type) return;
|
if (!columnInfo || !columnInfo[0])
|
||||||
|
throw new UserError(`Cannot fetch column values`);
|
||||||
|
|
||||||
let setValues;
|
let setValues;
|
||||||
setValues = type[0].column_type;
|
setValues = columnInfo[0].columnType
|
||||||
setValues = setValues.replace(/set\((.*)\)/i, '$1');
|
.replace(/^set\((.*)\)$/i, '$1')
|
||||||
setValues = setValues.replace(/'/g, '');
|
.replace(/'/g, '')
|
||||||
setValues = setValues.match(new RegExp(/(\w+)+/, 'ig'));
|
.match(new RegExp(/(\w+)+/, 'ig'));
|
||||||
|
|
||||||
let values = [];
|
let values = [];
|
||||||
setValues.forEach(setValue => {
|
setValues.forEach(setValue => {
|
||||||
|
|
|
@ -13,11 +13,4 @@ describe('Model getSetValues()', () => {
|
||||||
expect(result.length).toEqual(6);
|
expect(result.length).toEqual(6);
|
||||||
expect(result[5].value).toEqual('TABLET_VN');
|
expect(result[5].value).toEqual('TABLET_VN');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an array of set values from table column source_app', async() => {
|
|
||||||
let result = await app.models.Order.getSetValues('source_app');
|
|
||||||
|
|
||||||
expect(result.length).toEqual(6);
|
|
||||||
expect(result[5].value).toEqual('TABLET_VN');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,7 +34,11 @@ describe('Worker absences()', () => {
|
||||||
let workerFk = 106;
|
let workerFk = 106;
|
||||||
let worker = await app.models.WorkerLabour.findById(workerFk);
|
let worker = await app.models.WorkerLabour.findById(workerFk);
|
||||||
let endedDate = worker.ended;
|
let endedDate = worker.ended;
|
||||||
await worker.updateAttributes({ended: null});
|
|
||||||
|
await app.models.WorkerLabour.rawSql(
|
||||||
|
`UPDATE postgresql.business SET date_end = ? WHERE business_id = ?`,
|
||||||
|
[null, worker.businessFk]
|
||||||
|
);
|
||||||
|
|
||||||
let ctx = {req: {accessToken: {userId: 9}}};
|
let ctx = {req: {accessToken: {userId: 9}}};
|
||||||
|
|
||||||
|
@ -63,7 +67,10 @@ describe('Worker absences()', () => {
|
||||||
expect(sixthType).toEqual('Holidays');
|
expect(sixthType).toEqual('Holidays');
|
||||||
|
|
||||||
// restores the contract end date
|
// restores the contract end date
|
||||||
await worker.updateAttributes({ended: endedDate});
|
await app.models.WorkerLabour.rawSql(
|
||||||
|
`UPDATE postgresql.business SET date_end = ? WHERE business_id = ?`,
|
||||||
|
[endedDate, worker.businessFk]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should give the same holidays as worked days since the holidays amount matches the amount of days in a year', async() => {
|
it('should give the same holidays as worked days since the holidays amount matches the amount of days in a year', async() => {
|
||||||
|
@ -112,7 +119,10 @@ describe('Worker absences()', () => {
|
||||||
startingContract.setMonth(today.getMonth());
|
startingContract.setMonth(today.getMonth());
|
||||||
startingContract.setDate(1);
|
startingContract.setDate(1);
|
||||||
|
|
||||||
await contract.updateAttributes({started: startingContract});
|
await app.models.WorkerLabour.rawSql(
|
||||||
|
`UPDATE postgresql.business SET date_start = ? WHERE business_id = ?`,
|
||||||
|
[startingContract, contract.businessFk]
|
||||||
|
);
|
||||||
|
|
||||||
let ctx = {req: {accessToken: {userId: 106}}};
|
let ctx = {req: {accessToken: {userId: 106}}};
|
||||||
let workerFk = 106;
|
let workerFk = 106;
|
||||||
|
@ -148,6 +158,10 @@ describe('Worker absences()', () => {
|
||||||
days: originalHolidaysValue
|
days: originalHolidaysValue
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await contract.updateAttributes({started: contractStartDate});
|
|
||||||
|
await app.models.WorkerLabour.rawSql(
|
||||||
|
`UPDATE postgresql.business SET date_start = ? WHERE business_id = ?`,
|
||||||
|
[contractStartDate, contract.businessFk]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue