@verdnatura/myt 1.5.5 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/myt-push.js CHANGED
@@ -14,7 +14,8 @@ class Push extends Command {
14
14
  params: {
15
15
  force: 'Answer yes to all questions',
16
16
  commit: 'Wether to save the commit SHA into database',
17
- sums: 'Save SHA sums of pushed objects'
17
+ sums: 'Save SHA sums of pushed objects',
18
+ triggers: 'Wether to exclude triggers, used to generate local DB'
18
19
  },
19
20
  operand: 'remote'
20
21
  };
@@ -23,12 +24,14 @@ class Push extends Command {
23
24
  alias: {
24
25
  force: 'f',
25
26
  commit: 'c',
26
- sums: 's'
27
+ sums: 's',
28
+ triggers: 't'
27
29
  },
28
30
  boolean: [
29
31
  'force',
30
32
  'commit',
31
- 'sums'
33
+ 'sums',
34
+ 'triggers'
32
35
  ]
33
36
  };
34
37
 
@@ -297,6 +300,9 @@ class Push extends Command {
297
300
 
298
301
  for (const change of changes)
299
302
  try {
303
+ if (opts.trigger && change.type.name === 'TRIGGER')
304
+ continue;
305
+
300
306
  const schema = change.schema;
301
307
  const name = change.name;
302
308
  const type = change.type.name.toLowerCase();
package/myt-run.js CHANGED
@@ -40,7 +40,7 @@ class Run extends Command {
40
40
  if (!await fs.pathExists(`${dumpDir}/.dump.sql`))
41
41
  throw new Error('To run local database you have to create a dump first');
42
42
 
43
- // Build base server image
43
+ // Build base image
44
44
 
45
45
  let serverDockerfile = path.join(dumpDir, 'Dockerfile');
46
46
  if (!await fs.pathExists(serverDockerfile))
@@ -51,7 +51,7 @@ class Run extends Command {
51
51
  file: serverDockerfile
52
52
  }, opts.debug);
53
53
 
54
- // Build myt server image
54
+ // Build server image
55
55
 
56
56
  await docker.build(__dirname, {
57
57
  tag: 'myt/server',
@@ -60,17 +60,9 @@ class Run extends Command {
60
60
 
61
61
  // Build dump image
62
62
 
63
- const today = new Date();
64
- const pad = v => v < 10 ? '0' + v : v;
65
- const year = today.getFullYear();
66
- const month = pad(today.getMonth() + 1);
67
- const day = pad(today.getDate());
68
- const stamp = `${year}-${month}-${day}`;
69
-
70
63
  await docker.build(opts.mytDir, {
71
64
  tag: opts.code,
72
- file: path.join(serverDir, 'Dockerfile.dump'),
73
- buildArg: `STAMP=${stamp}`
65
+ file: path.join(serverDir, 'Dockerfile.dump')
74
66
  }, opts.debug);
75
67
 
76
68
  // Run container
@@ -98,7 +90,7 @@ class Run extends Command {
98
90
  Object.assign(runOptions, null, {
99
91
  env: `RUN_CHOWN=${runChown}`,
100
92
  detach: true,
101
- volume: `${path.join(dumpDir, 'fixtures.sql')}:/fixtures.sql:ro`
93
+ volume: `${this.opts.mytDir}:/workspace`
102
94
  });
103
95
  const ct = await docker.run(opts.code, null, runOptions);
104
96
  const server = new Server(ct, dbConfig);
@@ -125,6 +117,7 @@ class Run extends Command {
125
117
 
126
118
  Object.assign(opts, {
127
119
  commit: true,
120
+ trigger: true,
128
121
  dbConfig
129
122
  });
130
123
  await myt.runCommand(Push, opts);
@@ -133,7 +126,11 @@ class Run extends Command {
133
126
 
134
127
  console.log('Applying fixtures.');
135
128
  await ct.exec(null,
136
- 'docker-import.sh', ['/fixtures'], 'spawn', opts.debug);
129
+ 'docker-import.sh',
130
+ ['/workspace/dump/fixtures'],
131
+ 'spawn',
132
+ opts.debug
133
+ );
137
134
 
138
135
  // Create triggers
139
136
 
package/myt-start.js CHANGED
@@ -19,28 +19,32 @@ class Start extends Command {
19
19
  async run(myt, opts) {
20
20
  const ct = new Container(opts.code);
21
21
  let status;
22
+ let exists;
23
+ let server;
22
24
 
23
25
  try {
24
26
  status = await ct.inspect({
25
27
  format: '{{json .State.Status}}'
26
28
  });
29
+ exists = true;
27
30
  } catch (err) {
28
- const run = new Run()
29
- return await run.run(myt, opts);
31
+ server = await myt.runCommand(Run, opts);
30
32
  }
31
33
 
32
- switch (status) {
33
- case 'running':
34
- break;
35
- case 'exited':
36
- await ct.start();
37
- break;
38
- default:
39
- throw new Error(`Unknown docker status: ${status}`);
34
+ if (exists) {
35
+ switch (status) {
36
+ case 'running':
37
+ break;
38
+ case 'exited':
39
+ await ct.start();
40
+ server = new Server(ct, opts.dbConfig);
41
+ await server.wait();
42
+ break;
43
+ default:
44
+ throw new Error(`Unknown docker status: ${status}`);
45
+ }
40
46
  }
41
47
 
42
- const server = new Server(ct, opts.dbConfig);
43
- await server.wait();
44
48
  return server;
45
49
  }
46
50
  }
package/myt.js CHANGED
@@ -172,7 +172,7 @@ class Myt {
172
172
  async runCommand(CommandClass, opts) {
173
173
  const command = new CommandClass();
174
174
  command.opts = opts;
175
- await command.run(this, opts);
175
+ return await command.run(this, opts);
176
176
  }
177
177
 
178
178
  async load(opts) {
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "@verdnatura/myt",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "author": "Verdnatura Levante SL",
5
5
  "description": "MySQL version control",
6
6
  "license": "GPL-3.0",
7
7
  "bin": {
8
- "myt": "cli.js",
9
- "myvc": "cli.js",
10
- "myv": "cli.js"
8
+ "myt": "cli.js"
11
9
  },
12
10
  "repository": {
13
11
  "type": "git",
@@ -8,6 +8,6 @@
8
8
  "type": "git"
9
9
  },
10
10
  "dependencies": {
11
- "@verdnatura/myt": "^1.5.5"
11
+ "@verdnatura/myt": "^1.5.6"
12
12
  }
13
13
  }