#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: {
|
||||
force: 'Answer yes to all questions',
|
||||
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'
|
||||
};
|
||||
|
@ -23,12 +24,14 @@ class Push extends Command {
|
|||
alias: {
|
||||
force: 'f',
|
||||
commit: 'c',
|
||||
sums: 's'
|
||||
sums: 's',
|
||||
triggers: 't'
|
||||
},
|
||||
boolean: [
|
||||
'force',
|
||||
'commit',
|
||||
'sums'
|
||||
'sums',
|
||||
'triggers'
|
||||
]
|
||||
};
|
||||
|
||||
|
@ -297,6 +300,9 @@ class Push extends Command {
|
|||
|
||||
for (const change of changes)
|
||||
try {
|
||||
if (opts.trigger && change.type.name === 'TRIGGER')
|
||||
continue;
|
||||
|
||||
const schema = change.schema;
|
||||
const name = change.name;
|
||||
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`))
|
||||
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');
|
||||
if (!await fs.pathExists(serverDockerfile))
|
||||
|
@ -51,7 +51,7 @@ class Run extends Command {
|
|||
file: serverDockerfile
|
||||
}, opts.debug);
|
||||
|
||||
// Build myt server image
|
||||
// Build server image
|
||||
|
||||
await docker.build(__dirname, {
|
||||
tag: 'myt/server',
|
||||
|
@ -60,17 +60,9 @@ class Run extends Command {
|
|||
|
||||
// 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, {
|
||||
tag: opts.code,
|
||||
file: path.join(serverDir, 'Dockerfile.dump'),
|
||||
buildArg: `STAMP=${stamp}`
|
||||
file: path.join(serverDir, 'Dockerfile.dump')
|
||||
}, opts.debug);
|
||||
|
||||
// Run container
|
||||
|
@ -98,7 +90,7 @@ class Run extends Command {
|
|||
Object.assign(runOptions, null, {
|
||||
env: `RUN_CHOWN=${runChown}`,
|
||||
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 server = new Server(ct, dbConfig);
|
||||
|
@ -125,6 +117,7 @@ class Run extends Command {
|
|||
|
||||
Object.assign(opts, {
|
||||
commit: true,
|
||||
trigger: true,
|
||||
dbConfig
|
||||
});
|
||||
await myt.runCommand(Push, opts);
|
||||
|
@ -133,7 +126,11 @@ class Run extends Command {
|
|||
|
||||
console.log('Applying fixtures.');
|
||||
await ct.exec(null,
|
||||
'docker-import.sh', ['/fixtures'], 'spawn', opts.debug);
|
||||
'docker-import.sh',
|
||||
['/workspace/dump/fixtures'],
|
||||
'spawn',
|
||||
opts.debug
|
||||
);
|
||||
|
||||
// Create triggers
|
||||
|
||||
|
|
28
myt-start.js
28
myt-start.js
|
@ -19,28 +19,32 @@ class Start extends Command {
|
|||
async run(myt, opts) {
|
||||
const ct = new Container(opts.code);
|
||||
let status;
|
||||
let exists;
|
||||
let server;
|
||||
|
||||
try {
|
||||
status = await ct.inspect({
|
||||
format: '{{json .State.Status}}'
|
||||
});
|
||||
exists = true;
|
||||
} catch (err) {
|
||||
const run = new Run()
|
||||
return await run.run(myt, opts);
|
||||
server = await myt.runCommand(Run, opts);
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case 'running':
|
||||
break;
|
||||
case 'exited':
|
||||
await ct.start();
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown docker status: ${status}`);
|
||||
if (exists) {
|
||||
switch (status) {
|
||||
case 'running':
|
||||
break;
|
||||
case 'exited':
|
||||
await ct.start();
|
||||
server = new Server(ct, opts.dbConfig);
|
||||
await server.wait();
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown docker status: ${status}`);
|
||||
}
|
||||
}
|
||||
|
||||
const server = new Server(ct, opts.dbConfig);
|
||||
await server.wait();
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
|
2
myt.js
2
myt.js
|
@ -172,7 +172,7 @@ class Myt {
|
|||
async runCommand(CommandClass, opts) {
|
||||
const command = new CommandClass();
|
||||
command.opts = opts;
|
||||
await command.run(this, opts);
|
||||
return await command.run(this, opts);
|
||||
}
|
||||
|
||||
async load(opts) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.5",
|
||||
"version": "1.5.6",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.5",
|
||||
"version": "1.5.6",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@sqltools/formatter": "^1.2.3",
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
{
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.5",
|
||||
"version": "1.5.6",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "MySQL version control",
|
||||
"license": "GPL-3.0",
|
||||
"bin": {
|
||||
"myt": "cli.js",
|
||||
"myvc": "cli.js",
|
||||
"myv": "cli.js"
|
||||
"myt": "cli.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
"type": "git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@verdnatura/myt": "^1.5.5"
|
||||
"@verdnatura/myt": "^1.5.6"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue