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 TZ Europe/Madrid
|
||||
|
@ -7,36 +7,33 @@ ARG DEBIAN_FRONTEND=noninteractive
|
|||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends curl ca-certificates \
|
||||
&& 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 install -y --allow-unauthenticated vn-mysql \
|
||||
&& apt-get install -y vn-mysql libmysqlclient21 \
|
||||
&& apt-get purge -y --auto-remove curl ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# XXX: Removes the last script line to avoid daemon to be started
|
||||
RUN cp /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-init.sh \
|
||||
&& 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
|
||||
COPY docker/docker.cnf /etc/mysql/conf.d/
|
||||
COPY docker/docker-init.sh docker/docker-start.sh /usr/local/bin/
|
||||
|
||||
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/*
|
||||
|
||||
COPY docker-start.sh /usr/local/bin/
|
||||
USER mysql
|
||||
ENTRYPOINT ["docker-start.sh"]
|
||||
|
||||
USER mysql
|
||||
CMD ["mysqld", "--datadir", "/mysql-data"]
|
||||
CMD ["mysqld"]
|
||||
|
||||
#HEALTHCHECK --interval=5s --timeout=10s --retries=200 \
|
||||
# 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)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve el listado de agencias disponibles para la fecha,
|
||||
* dirección y warehouse pasadas
|
||||
* Devuelve el listado de agencias disponibles para la fecha,
|
||||
* dirección y almacén pasados.
|
||||
*
|
||||
* @param vAddress
|
||||
* @param vWarehouse warehouse
|
||||
|
@ -30,7 +30,8 @@ BEGIN
|
|||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||
JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk
|
||||
WHERE zw.warehouseFk
|
||||
GROUP BY z.agencyModeFk;
|
||||
GROUP BY z.agencyModeFk
|
||||
ORDER BY agencyMode;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
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
|
||||
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`.`address` AUTO_INCREMENT = 1;
|
||||
ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
|
||||
ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1;
|
||||
|
||||
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
|
||||
VALUES
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
-- Import compiled functions
|
||||
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 createNightmare from '../../helpers/nightmare';
|
||||
|
||||
describe('Claim development', () => {
|
||||
fdescribe('Claim development', () => {
|
||||
const nightmare = createNightmare();
|
||||
|
||||
beforeAll(() => {
|
||||
|
@ -116,16 +116,12 @@ describe('Claim development', () => {
|
|||
const responsible = await nightmare
|
||||
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimResponsibleAutocomplete} input`, 'value');
|
||||
|
||||
const worker = await nightmare
|
||||
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimWorkerAutocomplete} input`, 'value');
|
||||
|
||||
const redelivery = await nightmare
|
||||
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimRedeliveryAutocomplete} input`, 'value');
|
||||
|
||||
expect(reason).toEqual('Prisas');
|
||||
expect(result).toEqual('Otros daños');
|
||||
expect(responsible).toEqual('Compradores');
|
||||
expect(worker).toEqual('managerNick');
|
||||
expect(redelivery).toEqual('Cliente');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
/**
|
||||
* Returns a set of allowed values defined on table scheme
|
||||
|
@ -7,7 +9,6 @@ module.exports = Self => {
|
|||
Self.getSetValues = async function(column) {
|
||||
let model = this.app.models[this.modelName].definition;
|
||||
let properties = model.properties;
|
||||
let columnName;
|
||||
let tableName = this.modelName;
|
||||
let schema = null;
|
||||
|
||||
|
@ -17,35 +18,32 @@ module.exports = Self => {
|
|||
schema = tableSplit.pop() || null;
|
||||
}
|
||||
|
||||
if (properties[column]) {
|
||||
columnName = column;
|
||||
let property = properties[column];
|
||||
|
||||
if (properties[column].mysql)
|
||||
columnName = properties[column].mysql.columnName;
|
||||
}
|
||||
if (!property)
|
||||
throw new UserError(`Column does not exist`);
|
||||
|
||||
let findColumn = Object.keys(properties).find(prop => {
|
||||
return properties[prop].mysql && properties[prop].mysql.columnName === column;
|
||||
});
|
||||
let columnName = property.mysql
|
||||
? property.mysql.columnName
|
||||
: column;
|
||||
|
||||
if (findColumn)
|
||||
columnName = properties[findColumn].mysql.columnName;
|
||||
|
||||
let type = await this.rawSql(
|
||||
`SELECT DISTINCT column_type FROM information_schema.columns
|
||||
let columnInfo = await this.rawSql(
|
||||
`SELECT column_type columnType
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = ?
|
||||
AND table_schema = IFNULL(?, DATABASE())
|
||||
AND column_name = ?`,
|
||||
[tableName, schema, columnName]
|
||||
);
|
||||
|
||||
if (!type) return;
|
||||
if (!columnInfo || !columnInfo[0])
|
||||
throw new UserError(`Cannot fetch column values`);
|
||||
|
||||
let setValues;
|
||||
setValues = type[0].column_type;
|
||||
setValues = setValues.replace(/set\((.*)\)/i, '$1');
|
||||
setValues = setValues.replace(/'/g, '');
|
||||
setValues = setValues.match(new RegExp(/(\w+)+/, 'ig'));
|
||||
setValues = columnInfo[0].columnType
|
||||
.replace(/^set\((.*)\)$/i, '$1')
|
||||
.replace(/'/g, '')
|
||||
.match(new RegExp(/(\w+)+/, 'ig'));
|
||||
|
||||
let values = [];
|
||||
setValues.forEach(setValue => {
|
||||
|
|
|
@ -13,11 +13,4 @@ describe('Model getSetValues()', () => {
|
|||
expect(result.length).toEqual(6);
|
||||
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 worker = await app.models.WorkerLabour.findById(workerFk);
|
||||
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}}};
|
||||
|
||||
|
@ -63,7 +67,10 @@ describe('Worker absences()', () => {
|
|||
expect(sixthType).toEqual('Holidays');
|
||||
|
||||
// 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() => {
|
||||
|
@ -112,7 +119,10 @@ describe('Worker absences()', () => {
|
|||
startingContract.setMonth(today.getMonth());
|
||||
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 workerFk = 106;
|
||||
|
@ -148,6 +158,10 @@ describe('Worker absences()', () => {
|
|||
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