diff --git a/README.md b/README.md index e9982aa..152b87b 100644 --- a/README.md +++ b/README.md @@ -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 [] +$ myt dump [] [-l|--lock] ``` ### fixtures diff --git a/lib/dumper.js b/lib/dumper.js index 143f8ce..755d93d 100644 --- a/lib/dumper.js +++ b/lib/dumper.js @@ -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'); diff --git a/myt-dump.js b/myt-dump.js index 0e5d6b6..a1ec212 100644 --- a/myt-dump.js +++ b/myt-dump.js @@ -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); diff --git a/package-lock.json b/package-lock.json index 54d46ea..0a312af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": "" } diff --git a/package.json b/package.json index e3c2f2e..b4c5cb0 100644 --- a/package.json +++ b/package.json @@ -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",