#4550 Fixtures fix: triggers disabled, code clean, start fix
This commit is contained in:
parent
4e5f446e58
commit
0cb3ec8573
12
myt-push.js
12
myt-push.js
|
@ -14,7 +14,8 @@ class Push extends Command {
|
||||||
params: {
|
params: {
|
||||||
force: 'Answer yes to all questions',
|
force: 'Answer yes to all questions',
|
||||||
commit: 'Wether to save the commit SHA into database',
|
commit: 'Wether to save the commit SHA into database',
|
||||||
sums: 'Save SHA sums of pushed objects'
|
sums: 'Save SHA sums of pushed objects',
|
||||||
|
triggers: 'Wether to exclude triggers, used to generate local DB'
|
||||||
},
|
},
|
||||||
operand: 'remote'
|
operand: 'remote'
|
||||||
};
|
};
|
||||||
|
@ -23,12 +24,14 @@ class Push extends Command {
|
||||||
alias: {
|
alias: {
|
||||||
force: 'f',
|
force: 'f',
|
||||||
commit: 'c',
|
commit: 'c',
|
||||||
sums: 's'
|
sums: 's',
|
||||||
|
triggers: 't'
|
||||||
},
|
},
|
||||||
boolean: [
|
boolean: [
|
||||||
'force',
|
'force',
|
||||||
'commit',
|
'commit',
|
||||||
'sums'
|
'sums',
|
||||||
|
'triggers'
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -297,6 +300,9 @@ class Push extends Command {
|
||||||
|
|
||||||
for (const change of changes)
|
for (const change of changes)
|
||||||
try {
|
try {
|
||||||
|
if (opts.trigger && change.type.name === 'TRIGGER')
|
||||||
|
continue;
|
||||||
|
|
||||||
const schema = change.schema;
|
const schema = change.schema;
|
||||||
const name = change.name;
|
const name = change.name;
|
||||||
const type = change.type.name.toLowerCase();
|
const type = change.type.name.toLowerCase();
|
||||||
|
|
23
myt-run.js
23
myt-run.js
|
@ -40,7 +40,7 @@ class Run extends Command {
|
||||||
if (!await fs.pathExists(`${dumpDir}/.dump.sql`))
|
if (!await fs.pathExists(`${dumpDir}/.dump.sql`))
|
||||||
throw new Error('To run local database you have to create a dump first');
|
throw new Error('To run local database you have to create a dump first');
|
||||||
|
|
||||||
// Build base server image
|
// Build base image
|
||||||
|
|
||||||
let serverDockerfile = path.join(dumpDir, 'Dockerfile');
|
let serverDockerfile = path.join(dumpDir, 'Dockerfile');
|
||||||
if (!await fs.pathExists(serverDockerfile))
|
if (!await fs.pathExists(serverDockerfile))
|
||||||
|
@ -51,7 +51,7 @@ class Run extends Command {
|
||||||
file: serverDockerfile
|
file: serverDockerfile
|
||||||
}, opts.debug);
|
}, opts.debug);
|
||||||
|
|
||||||
// Build myt server image
|
// Build server image
|
||||||
|
|
||||||
await docker.build(__dirname, {
|
await docker.build(__dirname, {
|
||||||
tag: 'myt/server',
|
tag: 'myt/server',
|
||||||
|
@ -60,17 +60,9 @@ class Run extends Command {
|
||||||
|
|
||||||
// Build dump image
|
// Build dump image
|
||||||
|
|
||||||
const today = new Date();
|
|
||||||
const pad = v => v < 10 ? '0' + v : v;
|
|
||||||
const year = today.getFullYear();
|
|
||||||
const month = pad(today.getMonth() + 1);
|
|
||||||
const day = pad(today.getDate());
|
|
||||||
const stamp = `${year}-${month}-${day}`;
|
|
||||||
|
|
||||||
await docker.build(opts.mytDir, {
|
await docker.build(opts.mytDir, {
|
||||||
tag: opts.code,
|
tag: opts.code,
|
||||||
file: path.join(serverDir, 'Dockerfile.dump'),
|
file: path.join(serverDir, 'Dockerfile.dump')
|
||||||
buildArg: `STAMP=${stamp}`
|
|
||||||
}, opts.debug);
|
}, opts.debug);
|
||||||
|
|
||||||
// Run container
|
// Run container
|
||||||
|
@ -98,7 +90,7 @@ class Run extends Command {
|
||||||
Object.assign(runOptions, null, {
|
Object.assign(runOptions, null, {
|
||||||
env: `RUN_CHOWN=${runChown}`,
|
env: `RUN_CHOWN=${runChown}`,
|
||||||
detach: true,
|
detach: true,
|
||||||
volume: `${path.join(dumpDir, 'fixtures.sql')}:/fixtures.sql:ro`
|
volume: `${this.opts.mytDir}:/workspace`
|
||||||
});
|
});
|
||||||
const ct = await docker.run(opts.code, null, runOptions);
|
const ct = await docker.run(opts.code, null, runOptions);
|
||||||
const server = new Server(ct, dbConfig);
|
const server = new Server(ct, dbConfig);
|
||||||
|
@ -125,6 +117,7 @@ class Run extends Command {
|
||||||
|
|
||||||
Object.assign(opts, {
|
Object.assign(opts, {
|
||||||
commit: true,
|
commit: true,
|
||||||
|
trigger: true,
|
||||||
dbConfig
|
dbConfig
|
||||||
});
|
});
|
||||||
await myt.runCommand(Push, opts);
|
await myt.runCommand(Push, opts);
|
||||||
|
@ -133,7 +126,11 @@ class Run extends Command {
|
||||||
|
|
||||||
console.log('Applying fixtures.');
|
console.log('Applying fixtures.');
|
||||||
await ct.exec(null,
|
await ct.exec(null,
|
||||||
'docker-import.sh', ['/fixtures'], 'spawn', opts.debug);
|
'docker-import.sh',
|
||||||
|
['/workspace/dump/fixtures'],
|
||||||
|
'spawn',
|
||||||
|
opts.debug
|
||||||
|
);
|
||||||
|
|
||||||
// Create triggers
|
// Create triggers
|
||||||
|
|
||||||
|
|
28
myt-start.js
28
myt-start.js
|
@ -19,28 +19,32 @@ class Start extends Command {
|
||||||
async run(myt, opts) {
|
async run(myt, opts) {
|
||||||
const ct = new Container(opts.code);
|
const ct = new Container(opts.code);
|
||||||
let status;
|
let status;
|
||||||
|
let exists;
|
||||||
|
let server;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
status = await ct.inspect({
|
status = await ct.inspect({
|
||||||
format: '{{json .State.Status}}'
|
format: '{{json .State.Status}}'
|
||||||
});
|
});
|
||||||
|
exists = true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const run = new Run()
|
server = await myt.runCommand(Run, opts);
|
||||||
return await run.run(myt, opts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (status) {
|
if (exists) {
|
||||||
case 'running':
|
switch (status) {
|
||||||
break;
|
case 'running':
|
||||||
case 'exited':
|
break;
|
||||||
await ct.start();
|
case 'exited':
|
||||||
break;
|
await ct.start();
|
||||||
default:
|
server = new Server(ct, opts.dbConfig);
|
||||||
throw new Error(`Unknown docker status: ${status}`);
|
await server.wait();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown docker status: ${status}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = new Server(ct, opts.dbConfig);
|
|
||||||
await server.wait();
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
myt.js
2
myt.js
|
@ -172,7 +172,7 @@ class Myt {
|
||||||
async runCommand(CommandClass, opts) {
|
async runCommand(CommandClass, opts) {
|
||||||
const command = new CommandClass();
|
const command = new CommandClass();
|
||||||
command.opts = opts;
|
command.opts = opts;
|
||||||
await command.run(this, opts);
|
return await command.run(this, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
async load(opts) {
|
async load(opts) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.5",
|
"version": "1.5.6",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.5",
|
"version": "1.5.6",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sqltools/formatter": "^1.2.3",
|
"@sqltools/formatter": "^1.2.3",
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "@verdnatura/myt",
|
"name": "@verdnatura/myt",
|
||||||
"version": "1.5.5",
|
"version": "1.5.6",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "MySQL version control",
|
"description": "MySQL version control",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"myt": "cli.js",
|
"myt": "cli.js"
|
||||||
"myvc": "cli.js",
|
|
||||||
"myv": "cli.js"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
"type": "git"
|
"type": "git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@verdnatura/myt": "^1.5.5"
|
"@verdnatura/myt": "^1.5.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue