@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.
- package/assets/myt.default.yml +1 -0
- package/myt-dump.js +0 -10
- package/myt-init.js +15 -3
- package/myt-pull.js +10 -7
- package/myt-push.js +1 -1
- package/myt.js +1 -0
- package/package.json +1 -1
- package/template/dump/Dockerfile.base +1 -0
- package/template/dump/afterDump.sql +1 -0
- package/template/dump/beforeDump.sql +1 -0
- package/template/package.json +1 -1
- package/template/dump/structure.sql +0 -1
package/assets/myt.default.yml
CHANGED
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
|
|
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 =
|
|
18
|
+
const dst = path.join(opts.mytDir, template);
|
|
15
19
|
if (!await fs.pathExists(dst))
|
|
16
|
-
await fs.copy(
|
|
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
|
|
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
package/myt.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
FROM mariadb:10.7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- Executed after data dump
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- Executed before data dump
|
package/template/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-- Place your local structure changes here
|