@verdnatura/myt 1.5.8 → 1.5.9

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.
@@ -1,6 +1,7 @@
1
1
  versionSchema: myt
2
2
  versionDigits: 5
3
3
  maxOldVersions: 30
4
+ sumViews: true
4
5
  schemas:
5
6
  - myt
6
7
  fixtures:
package/myt-dump.js CHANGED
@@ -52,16 +52,6 @@ class Dump extends Command {
52
52
  }
53
53
 
54
54
  await dumper.end();
55
-
56
- console.log('Saving version.');
57
- await myt.dbConnect();
58
- const version = await myt.fetchDbVersion();
59
- if (version) {
60
- await fs.writeFile(
61
- `${opts.dumpDir}/.dump.json`,
62
- JSON.stringify(version)
63
- );
64
- }
65
55
  }
66
56
  }
67
57
 
package/myt-init.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const Myt = require('./myt');
2
2
  const Command = require('./lib/command');
3
3
  const fs = require('fs-extra');
4
+ const path = require('path');
4
5
 
5
6
  class Init extends Command {
6
7
  static usage = {
@@ -8,12 +9,23 @@ class Init extends Command {
8
9
  };
9
10
 
10
11
  async run(myt, opts) {
11
- const templateDir = `${__dirname}/template`;
12
+ const packageFile = path.join(opts.mytDir, 'package.json');
13
+ const packageExists = await fs.pathExists(packageFile);
14
+
15
+ const templateDir = path.join(__dirname, 'template');
12
16
  const templates = await fs.readdir(templateDir);
13
17
  for (let template of templates) {
14
- const dst = `${opts.mytDir}/${template}`;
18
+ const dst = path.join(opts.mytDir, template);
15
19
  if (!await fs.pathExists(dst))
16
- await fs.copy(`${templateDir}/${template}`, dst);
20
+ await fs.copy(path.join(templateDir, template), dst);
21
+ }
22
+
23
+ if (!packageExists) {
24
+ const packageJson = require(packageFile);
25
+ packageJson.dependencies[myt.packageJson.name] =
26
+ `^${myt.packageJson.version}`;
27
+ await fs.writeFile(packageFile,
28
+ JSON.stringify(packageJson, null, ' '));
17
29
  }
18
30
  }
19
31
  }
package/myt-pull.js CHANGED
@@ -125,9 +125,11 @@ class Pull extends Command {
125
125
  const {opts} = this;
126
126
 
127
127
  const res = await exporter.query(conn, schema);
128
- if (!res.length) return;
128
+ if (!res.length) return;
129
129
 
130
- const routineDir = `${opts.routinesDir}/${schema}/${exporter.objectType}s`;
130
+ const type = exporter.objectType;
131
+
132
+ const routineDir = `${opts.routinesDir}/${schema}/${type}s`;
131
133
  if (!await fs.pathExists(routineDir))
132
134
  await fs.mkdir(routineDir);
133
135
 
@@ -140,8 +142,10 @@ class Pull extends Command {
140
142
  const match = routineFile.match(/^(.*)\.sql$/);
141
143
  if (!match) continue;
142
144
  const routine = match[1];
143
- if (!routineSet.has(routine))
145
+ if (!routineSet.has(routine)) {
144
146
  await fs.remove(`${routineDir}/${routine}.sql`);
147
+ engine.deleteShaSum(type, schema, routine)
148
+ }
145
149
  }
146
150
 
147
151
  for (const params of res) {
@@ -150,12 +154,11 @@ class Pull extends Command {
150
154
  const routineFile = `${routineDir}/${routineName}.sql`;
151
155
  let update = opts.update;
152
156
 
153
- const oldSum = engine.getShaSum(routineName);
154
- if (oldSum || opts.sums) {
157
+ const oldSum = engine.getShaSum(type, schema, routineName);
158
+ if (oldSum || opts.sums || (opts.sumViews && type === 'view')) {
155
159
  const shaSum = engine.shaSum(sql);
156
160
  if (oldSum !== shaSum) {
157
- engine.setShaSum(
158
- exporter.objectType, schema, routineName, shaSum);
161
+ engine.setShaSum(type, schema, routineName, shaSum);
159
162
  update = true;
160
163
  }
161
164
  } else if (params.modified && engine.lastPull) {
package/myt-push.js CHANGED
@@ -349,7 +349,7 @@ class Push extends Command {
349
349
  );
350
350
  }
351
351
 
352
- if (opts.sums || oldSum)
352
+ if (opts.sums || oldSum || (opts.sumViews && type === 'view'))
353
353
  await engine.fetchShaSum(type, schema, name);
354
354
  } else {
355
355
  const escapedName =
package/myt.js CHANGED
@@ -45,6 +45,7 @@ class Myt {
45
45
  'Myt'.green,
46
46
  `v${packageJson.version}`.magenta
47
47
  );
48
+ this.packageJson = packageJson;
48
49
 
49
50
  let baseOpts = this.constructor.opts;
50
51
  baseOpts.default = Object.assign(baseOpts.default || {}, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdnatura/myt",
3
- "version": "1.5.8",
3
+ "version": "1.5.9",
4
4
  "author": "Verdnatura Levante SL",
5
5
  "description": "MySQL version control",
6
6
  "license": "GPL-3.0",
@@ -0,0 +1 @@
1
+ FROM mariadb:10.7
@@ -0,0 +1 @@
1
+ -- Executed after data dump
@@ -0,0 +1 @@
1
+ -- Executed before data dump
@@ -8,6 +8,6 @@
8
8
  "type": "git"
9
9
  },
10
10
  "dependencies": {
11
- "@verdnatura/myt": "^1.5.8"
11
+ "@verdnatura/myt": "^1.0.0"
12
12
  }
13
13
  }
@@ -1 +0,0 @@
1
- -- Place your local structure changes here