fixes #5421 push order/logging fix, check version fix, time mock
This commit is contained in:
parent
a8a9aac536
commit
a9d9e208c4
|
@ -1,6 +1,7 @@
|
||||||
versionSchema: myt
|
versionSchema: myt
|
||||||
versionDigits: 5
|
versionDigits: 5
|
||||||
maxOldVersions: 20
|
maxOldVersions: 20
|
||||||
|
mockDate: false
|
||||||
sumViews: true
|
sumViews: true
|
||||||
schemas:
|
schemas:
|
||||||
- myt
|
- myt
|
||||||
|
|
26
myt-push.js
26
myt-push.js
|
@ -321,16 +321,26 @@ class Push extends Command {
|
||||||
const oldSum = engine.getShaSum(type, schema, name);
|
const oldSum = engine.getShaSum(type, schema, name);
|
||||||
const isEqual = newSql == oldSql;
|
const isEqual = newSql == oldSql;
|
||||||
|
|
||||||
let actionMsg;
|
let statusMsg;
|
||||||
if ((exists && isEqual) || (!exists && !oldSql))
|
if (exists && !oldSql)
|
||||||
actionMsg = '[I]'.blue;
|
statusMsg = '[+]'.green;
|
||||||
else if (exists)
|
else if (!exists)
|
||||||
actionMsg = '[+]'.green;
|
statusMsg = '[-]'.red;
|
||||||
else
|
else
|
||||||
actionMsg = '[-]'.red;
|
statusMsg = '[·]'.yellow;
|
||||||
|
|
||||||
|
let actionMsg;
|
||||||
|
if (isEqual)
|
||||||
|
actionMsg = '[I]'.blue;
|
||||||
|
else
|
||||||
|
actionMsg = '[A]'.green;
|
||||||
|
|
||||||
const typeMsg = `[${change.type.abbr}]`[change.type.color];
|
const typeMsg = `[${change.type.abbr}]`[change.type.color];
|
||||||
console.log('', actionMsg.bold, typeMsg.bold, change.fullName);
|
console.log('',
|
||||||
|
(statusMsg + actionMsg).bold,
|
||||||
|
typeMsg.bold,
|
||||||
|
change.fullName
|
||||||
|
);
|
||||||
|
|
||||||
if (!isEqual) {
|
if (!isEqual) {
|
||||||
const scapedSchema = SqlString.escapeId(schema, true);
|
const scapedSchema = SqlString.escapeId(schema, true);
|
||||||
|
@ -475,7 +485,7 @@ class Push extends Command {
|
||||||
|
|
||||||
return routines.sort((a, b) => {
|
return routines.sort((a, b) => {
|
||||||
if (b.mark != a.mark)
|
if (b.mark != a.mark)
|
||||||
return b.mark == '-' ? 1 : -1;
|
return b.mark == '-' ? -1 : 1;
|
||||||
|
|
||||||
if (b.type.name !== a.type.name) {
|
if (b.type.name !== a.type.name) {
|
||||||
if (b.type.name == 'VIEW')
|
if (b.type.name == 'VIEW')
|
||||||
|
|
15
myt-run.js
15
myt-run.js
|
@ -6,6 +6,7 @@ const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Server = require('./lib/server');
|
const Server = require('./lib/server');
|
||||||
const connExt = require('./lib/conn');
|
const connExt = require('./lib/conn');
|
||||||
|
const SqlString = require('sqlstring');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the database image and runs a container. It only rebuilds the
|
* Builds the database image and runs a container. It only rebuilds the
|
||||||
|
@ -152,6 +153,20 @@ class Run extends Command {
|
||||||
await connExt.queryFromFile(conn, `${triggersPath}/${triggerFile}`);
|
await connExt.queryFromFile(conn, `${triggersPath}/${triggerFile}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mock date functions
|
||||||
|
|
||||||
|
console.log('Mocking date functions.');
|
||||||
|
const mockDateScript = path.join(dumpDir, 'mockDate.sql');
|
||||||
|
|
||||||
|
if (opts.mockDate) {
|
||||||
|
if (!await fs.pathExists(mockDateScript))
|
||||||
|
throw new Error(`Date mock enabled but mock script does not exist: ${mockDateScript}`);
|
||||||
|
|
||||||
|
let sql = await fs.readFile(mockDateScript, 'utf8');
|
||||||
|
sql = sql.replace(/@mockDate/g, SqlString.escape(opts.mockDate));
|
||||||
|
await connExt.multiQuery(conn, sql);
|
||||||
|
}
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
myt.js
4
myt.js
|
@ -120,8 +120,8 @@ class Myt {
|
||||||
const wsPackageJson = require(wsPackageFile);
|
const wsPackageJson = require(wsPackageFile);
|
||||||
try {
|
try {
|
||||||
depVersion = wsPackageJson
|
depVersion = wsPackageJson
|
||||||
.dependencies
|
.dependencies[packageJson.name]
|
||||||
.myt.match(versionRegex);
|
.match(versionRegex);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.14",
|
"version": "1.5.15",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.14",
|
"version": "1.5.15",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sqltools/formatter": "^1.2.5",
|
"@sqltools/formatter": "^1.2.5",
|
||||||
|
@ -722,9 +722,9 @@
|
||||||
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ=="
|
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ=="
|
||||||
},
|
},
|
||||||
"node_modules/http-cache-semantics": {
|
"node_modules/http-cache-semantics": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
|
||||||
"integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
|
"integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ=="
|
||||||
},
|
},
|
||||||
"node_modules/http-signature": {
|
"node_modules/http-signature": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
@ -2411,9 +2411,9 @@
|
||||||
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ=="
|
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ=="
|
||||||
},
|
},
|
||||||
"http-cache-semantics": {
|
"http-cache-semantics": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
|
||||||
"integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
|
"integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ=="
|
||||||
},
|
},
|
||||||
"http-signature": {
|
"http-signature": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.14",
|
"version": "1.5.15",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "MySQL version control",
|
"description": "MySQL version control",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
Loading…
Reference in New Issue