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
|
||||
versionDigits: 5
|
||||
maxOldVersions: 20
|
||||
mockDate: false
|
||||
sumViews: true
|
||||
schemas:
|
||||
- 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 isEqual = newSql == oldSql;
|
||||
|
||||
let actionMsg;
|
||||
if ((exists && isEqual) || (!exists && !oldSql))
|
||||
actionMsg = '[I]'.blue;
|
||||
else if (exists)
|
||||
actionMsg = '[+]'.green;
|
||||
let statusMsg;
|
||||
if (exists && !oldSql)
|
||||
statusMsg = '[+]'.green;
|
||||
else if (!exists)
|
||||
statusMsg = '[-]'.red;
|
||||
else
|
||||
actionMsg = '[-]'.red;
|
||||
statusMsg = '[·]'.yellow;
|
||||
|
||||
let actionMsg;
|
||||
if (isEqual)
|
||||
actionMsg = '[I]'.blue;
|
||||
else
|
||||
actionMsg = '[A]'.green;
|
||||
|
||||
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) {
|
||||
const scapedSchema = SqlString.escapeId(schema, true);
|
||||
|
@ -475,7 +485,7 @@ class Push extends Command {
|
|||
|
||||
return routines.sort((a, b) => {
|
||||
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 == 'VIEW')
|
||||
|
|
15
myt-run.js
15
myt-run.js
|
@ -6,6 +6,7 @@ const fs = require('fs-extra');
|
|||
const path = require('path');
|
||||
const Server = require('./lib/server');
|
||||
const connExt = require('./lib/conn');
|
||||
const SqlString = require('sqlstring');
|
||||
|
||||
/**
|
||||
* 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}`);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
4
myt.js
4
myt.js
|
@ -120,8 +120,8 @@ class Myt {
|
|||
const wsPackageJson = require(wsPackageFile);
|
||||
try {
|
||||
depVersion = wsPackageJson
|
||||
.dependencies
|
||||
.myt.match(versionRegex);
|
||||
.dependencies[packageJson.name]
|
||||
.match(versionRegex);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.14",
|
||||
"version": "1.5.15",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.14",
|
||||
"version": "1.5.15",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@sqltools/formatter": "^1.2.5",
|
||||
|
@ -722,9 +722,9 @@
|
|||
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ=="
|
||||
},
|
||||
"node_modules/http-cache-semantics": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
||||
"integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
|
||||
"integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ=="
|
||||
},
|
||||
"node_modules/http-signature": {
|
||||
"version": "1.2.0",
|
||||
|
@ -2411,9 +2411,9 @@
|
|||
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ=="
|
||||
},
|
||||
"http-cache-semantics": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
|
||||
"integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
|
||||
"integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ=="
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.2.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.14",
|
||||
"version": "1.5.15",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "MySQL version control",
|
||||
"license": "GPL-3.0",
|
||||
|
|
Loading…
Reference in New Issue