refs #5521 dump: don't lock tables by default, lock arg added
This commit is contained in:
parent
4e5fa85501
commit
fc68075240
|
@ -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.
|
in *dump* folder. If no remote is specified *production* is used.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
$ myt dump [<remote>]
|
$ myt dump [<remote>] [-l|--lock]
|
||||||
```
|
```
|
||||||
|
|
||||||
### fixtures
|
### fixtures
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = class Dumper {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async dumpFixtures(tables, replace) {
|
async dumpFixtures(tables, replace, args) {
|
||||||
const fixturesArgs = [
|
const fixturesArgs = [
|
||||||
'--no-create-info',
|
'--no-create-info',
|
||||||
'--skip-triggers',
|
'--skip-triggers',
|
||||||
|
@ -45,7 +45,7 @@ module.exports = class Dumper {
|
||||||
'--skip-set-charset',
|
'--skip-set-charset',
|
||||||
'--skip-comments',
|
'--skip-comments',
|
||||||
'--skip-tz-utc'
|
'--skip-tz-utc'
|
||||||
];
|
].concat(args);
|
||||||
|
|
||||||
if (replace)
|
if (replace)
|
||||||
fixturesArgs.push('--replace');
|
fixturesArgs.push('--replace');
|
||||||
|
|
21
myt-dump.js
21
myt-dump.js
|
@ -6,18 +6,30 @@ const Dumper = require('./lib/dumper');
|
||||||
class Dump extends Command {
|
class Dump extends Command {
|
||||||
static usage = {
|
static usage = {
|
||||||
description: 'Dumps structure and fixtures from remote',
|
description: 'Dumps structure and fixtures from remote',
|
||||||
|
params: {
|
||||||
|
lock: 'Whether to lock tables on dump'
|
||||||
|
},
|
||||||
operand: 'remote'
|
operand: 'remote'
|
||||||
};
|
};
|
||||||
|
|
||||||
static opts = {
|
static opts = {
|
||||||
default: {
|
default: {
|
||||||
remote: 'production'
|
remote: 'production'
|
||||||
}
|
},
|
||||||
|
alias: {
|
||||||
|
lock: 'l'
|
||||||
|
},
|
||||||
|
boolean: [
|
||||||
|
'lock'
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
async run(myt, opts) {
|
async run(myt, opts) {
|
||||||
const dumper = new Dumper(opts);
|
const dumper = new Dumper(opts);
|
||||||
await dumper.init('.dump.sql');
|
await dumper.init('.dump.sql');
|
||||||
|
const baseArgs = [
|
||||||
|
`--lock-tables=${opts.lock ? 'true' : 'false'}`
|
||||||
|
];
|
||||||
|
|
||||||
console.log('Dumping structure.');
|
console.log('Dumping structure.');
|
||||||
let dumpArgs = [
|
let dumpArgs = [
|
||||||
|
@ -28,12 +40,13 @@ class Dump extends Command {
|
||||||
'--events',
|
'--events',
|
||||||
'--skip-triggers',
|
'--skip-triggers',
|
||||||
'--databases'
|
'--databases'
|
||||||
];
|
].concat(baseArgs);
|
||||||
|
|
||||||
dumpArgs = dumpArgs.concat(opts.schemas);
|
dumpArgs = dumpArgs.concat(opts.schemas);
|
||||||
await dumper.runDump('docker-dump.sh', dumpArgs);
|
await dumper.runDump('docker-dump.sh', dumpArgs);
|
||||||
|
|
||||||
console.log('Dumping fixtures.');
|
console.log('Dumping fixtures.');
|
||||||
await dumper.dumpFixtures(opts.fixtures);
|
await dumper.dumpFixtures(opts.fixtures, false, baseArgs);
|
||||||
|
|
||||||
console.log('Dumping privileges.');
|
console.log('Dumping privileges.');
|
||||||
const privs = opts.privileges;
|
const privs = opts.privileges;
|
||||||
|
@ -43,7 +56,7 @@ class Dump extends Command {
|
||||||
'--skip-triggers',
|
'--skip-triggers',
|
||||||
'--insert-ignore',
|
'--insert-ignore',
|
||||||
'--complete-insert'
|
'--complete-insert'
|
||||||
];
|
].concat(baseArgs);
|
||||||
if (privs.where) args.push('--where', privs.where);
|
if (privs.where) args.push('--where', privs.where);
|
||||||
args = args.concat(['mysql'], privs.tables);
|
args = args.concat(['mysql'], privs.tables);
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
{
|
{
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.16",
|
"version": "1.5.17",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.16",
|
"version": "1.5.17",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sqltools/formatter": "^1.2.5",
|
"@sqltools/formatter": "^1.2.5",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"ejs": "^3.1.8",
|
"ejs": "^3.1.9",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"getopts": "^2.3.0",
|
"getopts": "^2.3.0",
|
||||||
"ini": "^1.3.8",
|
"ini": "^1.3.8",
|
||||||
"mysql2": "^2.3.3",
|
"mysql2": "^2.3.3",
|
||||||
"nodegit": "^0.27.0",
|
"nodegit": "^0.27.0",
|
||||||
"require-yaml": "0.0.1",
|
"require-yaml": "^0.0.1",
|
||||||
"sha.js": "^2.4.11"
|
"sha.js": "^2.4.11"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -462,9 +462,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ejs": {
|
"node_modules/ejs": {
|
||||||
"version": "3.1.8",
|
"version": "3.1.9",
|
||||||
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
|
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz",
|
||||||
"integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
|
"integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jake": "^10.8.5"
|
"jake": "^10.8.5"
|
||||||
},
|
},
|
||||||
|
@ -1463,7 +1463,7 @@
|
||||||
"node_modules/require-yaml": {
|
"node_modules/require-yaml": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/require-yaml/-/require-yaml-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/require-yaml/-/require-yaml-0.0.1.tgz",
|
||||||
"integrity": "sha1-LhsY2RPDuqcqWk03O28Tjd0sMr0=",
|
"integrity": "sha512-M6eVEgLPRbeOhgSCnOTtdrOOEQzbXRchg24Xa13c39dMuraFKdI9emUo97Rih0YEFzSICmSKg8w4RQp+rd9pOQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"js-yaml": ""
|
"js-yaml": ""
|
||||||
}
|
}
|
||||||
|
@ -2198,9 +2198,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ejs": {
|
"ejs": {
|
||||||
"version": "3.1.8",
|
"version": "3.1.9",
|
||||||
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
|
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz",
|
||||||
"integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
|
"integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"jake": "^10.8.5"
|
"jake": "^10.8.5"
|
||||||
}
|
}
|
||||||
|
@ -3017,7 +3017,7 @@
|
||||||
"require-yaml": {
|
"require-yaml": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/require-yaml/-/require-yaml-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/require-yaml/-/require-yaml-0.0.1.tgz",
|
||||||
"integrity": "sha1-LhsY2RPDuqcqWk03O28Tjd0sMr0=",
|
"integrity": "sha512-M6eVEgLPRbeOhgSCnOTtdrOOEQzbXRchg24Xa13c39dMuraFKdI9emUo97Rih0YEFzSICmSKg8w4RQp+rd9pOQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"js-yaml": ""
|
"js-yaml": ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.16",
|
"version": "1.5.17",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "MySQL version control",
|
"description": "MySQL version control",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sqltools/formatter": "^1.2.5",
|
"@sqltools/formatter": "^1.2.5",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"ejs": "^3.1.8",
|
"ejs": "^3.1.9",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"getopts": "^2.3.0",
|
"getopts": "^2.3.0",
|
||||||
"ini": "^1.3.8",
|
"ini": "^1.3.8",
|
||||||
"mysql2": "^2.3.3",
|
"mysql2": "^2.3.3",
|
||||||
"nodegit": "^0.27.0",
|
"nodegit": "^0.27.0",
|
||||||
"require-yaml": "0.0.1",
|
"require-yaml": "^0.0.1",
|
||||||
"sha.js": "^2.4.11"
|
"sha.js": "^2.4.11"
|
||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|
Loading…
Reference in New Issue