dump: Dump privileges
This commit is contained in:
parent
0c7ee1d312
commit
74561dbd6b
|
@ -146,7 +146,8 @@ routines.
|
||||||
|
|
||||||
You can create your local fixture and structure files.
|
You can create your local fixture and structure files.
|
||||||
|
|
||||||
* *dump/structure.sql*
|
* *dump/beforeDump.sql*
|
||||||
|
* *dump/afterDump.sql*
|
||||||
* *dump/fixtures.sql*
|
* *dump/fixtures.sql*
|
||||||
|
|
||||||
## Versioning commands
|
## Versioning commands
|
||||||
|
|
20
myvc-dump.js
20
myvc-dump.js
|
@ -22,6 +22,7 @@ class Dump {
|
||||||
async run(myvc, opts) {
|
async run(myvc, opts) {
|
||||||
const dumpStream = await myvc.initDump('.dump.sql');
|
const dumpStream = await myvc.initDump('.dump.sql');
|
||||||
|
|
||||||
|
console.log('Dumping structure.');
|
||||||
let dumpArgs = [
|
let dumpArgs = [
|
||||||
'--default-character-set=utf8',
|
'--default-character-set=utf8',
|
||||||
'--no-data',
|
'--no-data',
|
||||||
|
@ -34,9 +35,28 @@ class Dump {
|
||||||
dumpArgs = dumpArgs.concat(opts.schemas);
|
dumpArgs = dumpArgs.concat(opts.schemas);
|
||||||
await myvc.runDump('myvc-dump.sh', dumpArgs, dumpStream);
|
await myvc.runDump('myvc-dump.sh', dumpArgs, dumpStream);
|
||||||
|
|
||||||
|
console.log('Dumping fixtures.');
|
||||||
await myvc.dumpFixtures(dumpStream, opts.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();
|
await dumpStream.end();
|
||||||
|
|
||||||
|
console.log('Saving version.');
|
||||||
await myvc.dbConnect();
|
await myvc.dbConnect();
|
||||||
const version = await myvc.fetchDbVersion();
|
const version = await myvc.fetchDbVersion();
|
||||||
if (version) {
|
if (version) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "myvc",
|
"name": "myvc",
|
||||||
"version": "1.4.14",
|
"version": "1.4.15",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "myvc",
|
"name": "myvc",
|
||||||
"version": "1.4.14",
|
"version": "1.4.15",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sqltools/formatter": "^1.2.3",
|
"@sqltools/formatter": "^1.2.3",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "myvc",
|
"name": "myvc",
|
||||||
"version": "1.4.14",
|
"version": "1.4.15",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "MySQL Version Control",
|
"description": "MySQL Version Control",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
|
@ -4,14 +4,16 @@ USER root
|
||||||
|
|
||||||
COPY \
|
COPY \
|
||||||
dump/.dump.sql \
|
dump/.dump.sql \
|
||||||
dump/structure.sql \
|
dump/beforeDump.sql \
|
||||||
|
dump/afterDump.sql \
|
||||||
dump/
|
dump/
|
||||||
COPY myvc.config.yml \
|
COPY myvc.config.yml \
|
||||||
./
|
./
|
||||||
|
|
||||||
RUN gosu mysql docker-init.sh \
|
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/.dump \
|
||||||
|
&& docker-dump.sh dump/afterDump \
|
||||||
&& gosu mysql docker-temp-stop.sh
|
&& gosu mysql docker-temp-stop.sh
|
||||||
|
|
||||||
COPY routines routines
|
COPY routines routines
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
"type": "git"
|
"type": "git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"myvc": "^1.4.14"
|
"myvc": "^1.4.15"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue