dump: Dump privileges

This commit is contained in:
Juan Ferrer 2022-07-12 09:45:05 +02:00
parent 0c7ee1d312
commit 74561dbd6b
6 changed files with 30 additions and 7 deletions

View File

@ -146,7 +146,8 @@ routines.
You can create your local fixture and structure files.
* *dump/structure.sql*
* *dump/beforeDump.sql*
* *dump/afterDump.sql*
* *dump/fixtures.sql*
## Versioning commands

View File

@ -22,6 +22,7 @@ class Dump {
async run(myvc, opts) {
const dumpStream = await myvc.initDump('.dump.sql');
console.log('Dumping structure.');
let dumpArgs = [
'--default-character-set=utf8',
'--no-data',
@ -34,9 +35,28 @@ class Dump {
dumpArgs = dumpArgs.concat(opts.schemas);
await myvc.runDump('myvc-dump.sh', dumpArgs, dumpStream);
console.log('Dumping fixtures.');
await myvc.dumpFixtures(dumpStream, opts.fixtures);
console.log('Dumping privileges.');
const privs = opts.privileges;
if (privs && Array.isArray(privs.tables)) {
let args = [
'--no-create-info',
'--skip-triggers',
'--insert-ignore',
'--complete-insert'
];
if (privs.where) args.push('--where', privs.where);
args = args.concat(['mysql'], privs.tables);
await dumpStream.write('USE `mysql`;\n', 'utf8');
await myvc.runDump('myvc-dump.sh', args, dumpStream);
}
await dumpStream.end();
console.log('Saving version.');
await myvc.dbConnect();
const version = await myvc.fetchDbVersion();
if (version) {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "myvc",
"version": "1.4.14",
"version": "1.4.15",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "myvc",
"version": "1.4.14",
"version": "1.4.15",
"license": "GPL-3.0",
"dependencies": {
"@sqltools/formatter": "^1.2.3",

View File

@ -1,6 +1,6 @@
{
"name": "myvc",
"version": "1.4.14",
"version": "1.4.15",
"author": "Verdnatura Levante SL",
"description": "MySQL Version Control",
"license": "GPL-3.0",

View File

@ -4,14 +4,16 @@ USER root
COPY \
dump/.dump.sql \
dump/structure.sql \
dump/beforeDump.sql \
dump/afterDump.sql \
dump/
COPY myvc.config.yml \
./
RUN gosu mysql docker-init.sh \
&& docker-dump.sh dump/structure \
&& docker-dump.sh dump/beforeDump \
&& docker-dump.sh dump/.dump \
&& docker-dump.sh dump/afterDump \
&& gosu mysql docker-temp-stop.sh
COPY routines routines

View File

@ -8,6 +8,6 @@
"type": "git"
},
"dependencies": {
"myvc": "^1.4.14"
"myvc": "^1.4.15"
}
}