refs #5521 dump: don't lock tables by default, lock arg added

This commit is contained in:
Juan Ferrer 2023-04-05 10:11:31 +02:00
parent 4e5fa85501
commit fc68075240
5 changed files with 35 additions and 22 deletions

View File

@ -221,7 +221,7 @@ Exports database structure and fixtures from remote into hidden files located
in *dump* folder. If no remote is specified *production* is used.
```text
$ myt dump [<remote>]
$ myt dump [<remote>] [-l|--lock]
```
### fixtures

View File

@ -35,7 +35,7 @@ module.exports = class Dumper {
);
}
async dumpFixtures(tables, replace) {
async dumpFixtures(tables, replace, args) {
const fixturesArgs = [
'--no-create-info',
'--skip-triggers',
@ -45,7 +45,7 @@ module.exports = class Dumper {
'--skip-set-charset',
'--skip-comments',
'--skip-tz-utc'
];
].concat(args);
if (replace)
fixturesArgs.push('--replace');

View File

@ -6,18 +6,30 @@ const Dumper = require('./lib/dumper');
class Dump extends Command {
static usage = {
description: 'Dumps structure and fixtures from remote',
params: {
lock: 'Whether to lock tables on dump'
},
operand: 'remote'
};
static opts = {
default: {
remote: 'production'
}
},
alias: {
lock: 'l'
},
boolean: [
'lock'
]
};
async run(myt, opts) {
const dumper = new Dumper(opts);
await dumper.init('.dump.sql');
const baseArgs = [
`--lock-tables=${opts.lock ? 'true' : 'false'}`
];
console.log('Dumping structure.');
let dumpArgs = [
@ -28,12 +40,13 @@ class Dump extends Command {
'--events',
'--skip-triggers',
'--databases'
];
].concat(baseArgs);
dumpArgs = dumpArgs.concat(opts.schemas);
await dumper.runDump('docker-dump.sh', dumpArgs);
console.log('Dumping fixtures.');
await dumper.dumpFixtures(opts.fixtures);
await dumper.dumpFixtures(opts.fixtures, false, baseArgs);
console.log('Dumping privileges.');
const privs = opts.privileges;
@ -43,7 +56,7 @@ class Dump extends Command {
'--skip-triggers',
'--insert-ignore',
'--complete-insert'
];
].concat(baseArgs);
if (privs.where) args.push('--where', privs.where);
args = args.concat(['mysql'], privs.tables);

24
package-lock.json generated
View File

@ -1,23 +1,23 @@
{
"name": "@verdnatura/myt",
"version": "1.5.16",
"version": "1.5.17",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@verdnatura/myt",
"version": "1.5.16",
"version": "1.5.17",
"license": "GPL-3.0",
"dependencies": {
"@sqltools/formatter": "^1.2.5",
"colors": "^1.4.0",
"ejs": "^3.1.8",
"ejs": "^3.1.9",
"fs-extra": "^8.1.0",
"getopts": "^2.3.0",
"ini": "^1.3.8",
"mysql2": "^2.3.3",
"nodegit": "^0.27.0",
"require-yaml": "0.0.1",
"require-yaml": "^0.0.1",
"sha.js": "^2.4.11"
},
"bin": {
@ -462,9 +462,9 @@
}
},
"node_modules/ejs": {
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
"integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
"version": "3.1.9",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz",
"integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==",
"dependencies": {
"jake": "^10.8.5"
},
@ -1463,7 +1463,7 @@
"node_modules/require-yaml": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/require-yaml/-/require-yaml-0.0.1.tgz",
"integrity": "sha1-LhsY2RPDuqcqWk03O28Tjd0sMr0=",
"integrity": "sha512-M6eVEgLPRbeOhgSCnOTtdrOOEQzbXRchg24Xa13c39dMuraFKdI9emUo97Rih0YEFzSICmSKg8w4RQp+rd9pOQ==",
"dependencies": {
"js-yaml": ""
}
@ -2198,9 +2198,9 @@
}
},
"ejs": {
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
"integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
"version": "3.1.9",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz",
"integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==",
"requires": {
"jake": "^10.8.5"
}
@ -3017,7 +3017,7 @@
"require-yaml": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/require-yaml/-/require-yaml-0.0.1.tgz",
"integrity": "sha1-LhsY2RPDuqcqWk03O28Tjd0sMr0=",
"integrity": "sha512-M6eVEgLPRbeOhgSCnOTtdrOOEQzbXRchg24Xa13c39dMuraFKdI9emUo97Rih0YEFzSICmSKg8w4RQp+rd9pOQ==",
"requires": {
"js-yaml": ""
}

View File

@ -1,6 +1,6 @@
{
"name": "@verdnatura/myt",
"version": "1.5.16",
"version": "1.5.17",
"author": "Verdnatura Levante SL",
"description": "MySQL version control",
"license": "GPL-3.0",
@ -14,13 +14,13 @@
"dependencies": {
"@sqltools/formatter": "^1.2.5",
"colors": "^1.4.0",
"ejs": "^3.1.8",
"ejs": "^3.1.9",
"fs-extra": "^8.1.0",
"getopts": "^2.3.0",
"ini": "^1.3.8",
"mysql2": "^2.3.3",
"nodegit": "^0.27.0",
"require-yaml": "0.0.1",
"require-yaml": "^0.0.1",
"sha.js": "^2.4.11"
},
"main": "index.js",