dbgate-tools 6.4.3-alpha.1 → 6.5.0

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,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -33,10 +24,16 @@ const STRUCTURE_FIELDS = [
33
24
  ];
34
25
  const fp_pick = arg => array => (0, pick_1.default)(array, arg);
35
26
  function mergeTableRowCounts(info, rowCounts) {
36
- return Object.assign(Object.assign({}, info), { tables: (info.tables || []).map(table => {
27
+ return {
28
+ ...info,
29
+ tables: (info.tables || []).map(table => {
37
30
  var _a, _b;
38
- return (Object.assign(Object.assign({}, table), { tableRowCount: (_b = (_a = rowCounts.find(x => x.objectId == table.objectId)) === null || _a === void 0 ? void 0 : _a.tableRowCount) !== null && _b !== void 0 ? _b : table.tableRowCount }));
39
- }) });
31
+ return ({
32
+ ...table,
33
+ tableRowCount: (_b = (_a = rowCounts.find(x => x.objectId == table.objectId)) === null || _a === void 0 ? void 0 : _a.tableRowCount) !== null && _b !== void 0 ? _b : table.tableRowCount,
34
+ });
35
+ }),
36
+ };
40
37
  }
41
38
  function areDifferentRowCounts(db1, db2) {
42
39
  for (const t1 of db1.tables || []) {
@@ -55,19 +52,13 @@ class DatabaseAnalyser {
55
52
  this.dialect = ((driver === null || driver === void 0 ? void 0 : driver.dialectByVersion) && (driver === null || driver === void 0 ? void 0 : driver.dialectByVersion(version))) || (driver === null || driver === void 0 ? void 0 : driver.dialect);
56
53
  this.logger = logger;
57
54
  }
58
- _runAnalysis() {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- return DatabaseAnalyser.createEmptyStructure();
61
- });
62
- }
63
- _getFastSnapshot() {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- return null;
66
- });
55
+ async _runAnalysis() {
56
+ return DatabaseAnalyser.createEmptyStructure();
67
57
  }
68
- _computeSingleObjectId() {
69
- return __awaiter(this, void 0, void 0, function* () { });
58
+ async _getFastSnapshot() {
59
+ return null;
70
60
  }
61
+ async _computeSingleObjectId() { }
71
62
  addEngineField(db) {
72
63
  var _a;
73
64
  if (!((_a = this.driver) === null || _a === void 0 ? void 0 : _a.engine))
@@ -82,61 +73,58 @@ class DatabaseAnalyser {
82
73
  db.engine = this.driver.engine;
83
74
  return db;
84
75
  }
85
- fullAnalysis() {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- logger.debug(`Performing full analysis, DB=${(0, schemaInfoTools_1.dbNameLogCategory)(this.dbhan.database)}, engine=${this.driver.engine}`);
88
- const res = this.addEngineField(yield this._runAnalysis());
89
- // console.log('FULL ANALYSIS', res);
90
- return res;
91
- });
76
+ async fullAnalysis() {
77
+ logger.debug(`Performing full analysis, DB=${(0, schemaInfoTools_1.dbNameLogCategory)(this.dbhan.database)}, engine=${this.driver.engine}`);
78
+ const res = this.addEngineField(await this._runAnalysis());
79
+ // console.log('FULL ANALYSIS', res);
80
+ return res;
92
81
  }
93
- singleObjectAnalysis(name, typeField) {
82
+ async singleObjectAnalysis(name, typeField) {
94
83
  var _a, _b, _c;
95
- return __awaiter(this, void 0, void 0, function* () {
96
- // console.log('Analysing SINGLE OBJECT', name, typeField);
97
- this.singleObjectFilter = Object.assign(Object.assign({}, name), { typeField });
98
- yield this._computeSingleObjectId();
99
- const res = this.addEngineField(yield this._runAnalysis());
100
- // console.log('SINGLE OBJECT RES', JSON.stringify(res, null, 2));
101
- const obj = ((_a = res[typeField]) === null || _a === void 0 ? void 0 : _a.length) == 1
102
- ? (_b = res[typeField]) === null || _b === void 0 ? void 0 : _b.find(x => x.pureName.toLowerCase() == name.pureName.toLowerCase())
103
- : (_c = res[typeField]) === null || _c === void 0 ? void 0 : _c.find(x => x.pureName == name.pureName && x.schemaName == name.schemaName);
104
- // console.log('SINGLE OBJECT', obj);
105
- return obj;
106
- });
84
+ // console.log('Analysing SINGLE OBJECT', name, typeField);
85
+ this.singleObjectFilter = { ...name, typeField };
86
+ await this._computeSingleObjectId();
87
+ const res = this.addEngineField(await this._runAnalysis());
88
+ // console.log('SINGLE OBJECT RES', JSON.stringify(res, null, 2));
89
+ const obj = ((_a = res[typeField]) === null || _a === void 0 ? void 0 : _a.length) == 1
90
+ ? (_b = res[typeField]) === null || _b === void 0 ? void 0 : _b.find(x => x.pureName.toLowerCase() == name.pureName.toLowerCase())
91
+ : (_c = res[typeField]) === null || _c === void 0 ? void 0 : _c.find(x => x.pureName == name.pureName && x.schemaName == name.schemaName);
92
+ // console.log('SINGLE OBJECT', obj);
93
+ return obj;
107
94
  }
108
- incrementalAnalysis(structure) {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- logger.info(`Performing incremental analysis, DB=${(0, schemaInfoTools_1.dbNameLogCategory)(this.dbhan.database)}, engine=${this.driver.engine}`);
111
- this.structure = structure;
112
- const modifications = yield this.getModifications();
113
- if (modifications == null) {
114
- // modifications not implemented, perform full analysis
115
- this.structure = null;
116
- return this.addEngineField(yield this._runAnalysis());
117
- }
118
- const structureModifications = modifications.filter(x => x.action != 'setTableRowCounts');
119
- const setTableRowCounts = modifications.find(x => x.action == 'setTableRowCounts');
120
- let structureWithRowCounts = null;
121
- if (setTableRowCounts) {
122
- const newStructure = mergeTableRowCounts(structure, setTableRowCounts.rowCounts);
123
- if (areDifferentRowCounts(structure, newStructure)) {
124
- structureWithRowCounts = newStructure;
125
- }
126
- }
127
- if (structureModifications.length == 0) {
128
- return structureWithRowCounts ? this.addEngineField(structureWithRowCounts) : null;
95
+ async incrementalAnalysis(structure) {
96
+ logger.info(`Performing incremental analysis, DB=${(0, schemaInfoTools_1.dbNameLogCategory)(this.dbhan.database)}, engine=${this.driver.engine}`);
97
+ this.structure = structure;
98
+ const modifications = await this.getModifications();
99
+ if (modifications == null) {
100
+ // modifications not implemented, perform full analysis
101
+ this.structure = null;
102
+ return this.addEngineField(await this._runAnalysis());
103
+ }
104
+ const structureModifications = modifications.filter(x => x.action != 'setTableRowCounts');
105
+ const setTableRowCounts = modifications.find(x => x.action == 'setTableRowCounts');
106
+ let structureWithRowCounts = null;
107
+ if (setTableRowCounts) {
108
+ const newStructure = mergeTableRowCounts(structure, setTableRowCounts.rowCounts);
109
+ if (areDifferentRowCounts(structure, newStructure)) {
110
+ structureWithRowCounts = newStructure;
129
111
  }
130
- this.modifications = structureModifications;
131
- if (structureWithRowCounts)
132
- this.structure = structureWithRowCounts;
133
- logger.info({ modifications: this.modifications }, 'DB modifications detected:');
134
- return this.addEngineField(this.mergeAnalyseResult(yield this._runAnalysis()));
135
- });
112
+ }
113
+ if (structureModifications.length == 0) {
114
+ return structureWithRowCounts ? this.addEngineField(structureWithRowCounts) : null;
115
+ }
116
+ this.modifications = structureModifications;
117
+ if (structureWithRowCounts)
118
+ this.structure = structureWithRowCounts;
119
+ logger.info({ modifications: this.modifications }, 'DB modifications detected:');
120
+ return this.addEngineField(this.mergeAnalyseResult(await this._runAnalysis()));
136
121
  }
137
122
  mergeAnalyseResult(newlyAnalysed) {
138
123
  if (this.structure == null) {
139
- return Object.assign(Object.assign({}, DatabaseAnalyser.createEmptyStructure()), newlyAnalysed);
124
+ return {
125
+ ...DatabaseAnalyser.createEmptyStructure(),
126
+ ...newlyAnalysed,
127
+ };
140
128
  }
141
129
  const res = {};
142
130
  for (const field of STRUCTURE_FIELDS) {
@@ -261,82 +249,78 @@ class DatabaseAnalyser {
261
249
  logger.debug(obj.analysingMessage);
262
250
  }
263
251
  }
264
- getModifications() {
265
- return __awaiter(this, void 0, void 0, function* () {
266
- const snapshot = yield this._getFastSnapshot();
267
- if (!snapshot)
268
- return null;
269
- // console.log('STRUCTURE', this.structure);
270
- // console.log('SNAPSHOT', snapshot);
271
- const res = [];
272
- for (const field in snapshot) {
273
- const items = snapshot[field];
274
- if (items === null) {
275
- res.push({ objectTypeField: field, action: 'all' });
276
- continue;
277
- }
278
- if (items === undefined) {
279
- // skip - undefined meens, that field is not supported
280
- continue;
281
- }
282
- for (const item of items) {
283
- const { objectId, schemaName, pureName, contentHash } = item;
284
- const obj = this.structure[field].find(x => x.objectId == objectId);
285
- if (obj && contentHash && obj.contentHash == contentHash)
286
- continue;
287
- const action = obj
288
- ? {
289
- newName: { schemaName, pureName },
290
- oldName: (0, pick_1.default)(obj, ['schemaName', 'pureName']),
291
- action: 'change',
292
- objectTypeField: field,
293
- objectId,
294
- }
295
- : {
296
- newName: { schemaName, pureName },
297
- action: 'add',
298
- objectTypeField: field,
299
- objectId,
300
- };
301
- res.push(action);
302
- }
303
- }
304
- const rowCounts = (snapshot.tables || [])
305
- .filter(x => x.tableRowCount != null)
306
- .map(x => ({
307
- objectId: x.objectId,
308
- tableRowCount: x.tableRowCount,
309
- }));
310
- if (rowCounts.length > 0) {
311
- res.push({
312
- action: 'setTableRowCounts',
313
- rowCounts,
314
- });
315
- }
316
- return [...(0, compact_1.default)(res), ...this.getDeletedObjects(snapshot)];
317
- });
318
- }
319
- analyserQuery(template, typeFields, replacements = {}) {
320
- return __awaiter(this, void 0, void 0, function* () {
321
- const sql = this.createQuery(template, typeFields, replacements);
322
- if (!sql) {
323
- return {
324
- rows: [],
325
- };
252
+ async getModifications() {
253
+ const snapshot = await this._getFastSnapshot();
254
+ if (!snapshot)
255
+ return null;
256
+ // console.log('STRUCTURE', this.structure);
257
+ // console.log('SNAPSHOT', snapshot);
258
+ const res = [];
259
+ for (const field in snapshot) {
260
+ const items = snapshot[field];
261
+ if (items === null) {
262
+ res.push({ objectTypeField: field, action: 'all' });
263
+ continue;
326
264
  }
327
- try {
328
- const res = yield this.driver.query(this.dbhan, sql);
329
- this.logger.debug({ rows: res.rows.length, template }, `Loaded analyser query`);
330
- return res;
265
+ if (items === undefined) {
266
+ // skip - undefined meens, that field is not supported
267
+ continue;
331
268
  }
332
- catch (err) {
333
- logger.error((0, stringTools_1.extractErrorLogData)(err, { template }), 'Error running analyser query');
334
- return {
335
- rows: [],
336
- isError: true,
337
- };
269
+ for (const item of items) {
270
+ const { objectId, schemaName, pureName, contentHash } = item;
271
+ const obj = this.structure[field].find(x => x.objectId == objectId);
272
+ if (obj && contentHash && obj.contentHash == contentHash)
273
+ continue;
274
+ const action = obj
275
+ ? {
276
+ newName: { schemaName, pureName },
277
+ oldName: (0, pick_1.default)(obj, ['schemaName', 'pureName']),
278
+ action: 'change',
279
+ objectTypeField: field,
280
+ objectId,
281
+ }
282
+ : {
283
+ newName: { schemaName, pureName },
284
+ action: 'add',
285
+ objectTypeField: field,
286
+ objectId,
287
+ };
288
+ res.push(action);
338
289
  }
339
- });
290
+ }
291
+ const rowCounts = (snapshot.tables || [])
292
+ .filter(x => x.tableRowCount != null)
293
+ .map(x => ({
294
+ objectId: x.objectId,
295
+ tableRowCount: x.tableRowCount,
296
+ }));
297
+ if (rowCounts.length > 0) {
298
+ res.push({
299
+ action: 'setTableRowCounts',
300
+ rowCounts,
301
+ });
302
+ }
303
+ return [...(0, compact_1.default)(res), ...this.getDeletedObjects(snapshot)];
304
+ }
305
+ async analyserQuery(template, typeFields, replacements = {}) {
306
+ const sql = this.createQuery(template, typeFields, replacements);
307
+ if (!sql) {
308
+ return {
309
+ rows: [],
310
+ };
311
+ }
312
+ try {
313
+ const res = await this.driver.query(this.dbhan, sql);
314
+ this.logger.debug({ rows: res.rows.length, template }, `Loaded analyser query`);
315
+ return res;
316
+ }
317
+ catch (err) {
318
+ logger.error((0, stringTools_1.extractErrorLogData)(err, { template }), 'Error running analyser query');
319
+ return {
320
+ rows: [],
321
+ isError: true,
322
+ };
323
+ }
340
324
  }
341
325
  static createEmptyStructure() {
342
326
  return {
@@ -357,19 +341,28 @@ class DatabaseAnalyser {
357
341
  const filtered = pkColumns.filter(DatabaseAnalyser.byTableFilter(table));
358
342
  if (filtered.length == 0)
359
343
  return undefined;
360
- return Object.assign(Object.assign({}, (0, pick_1.default)(filtered[0], ['constraintName', 'schemaName', 'pureName'])), { constraintType: 'primaryKey', columns: filtered.map(fp_pick('columnName')) });
344
+ return {
345
+ ...(0, pick_1.default)(filtered[0], ['constraintName', 'schemaName', 'pureName']),
346
+ constraintType: 'primaryKey',
347
+ columns: filtered.map(fp_pick('columnName')),
348
+ };
361
349
  }
362
350
  static extractForeignKeys(table, fkColumns) {
363
351
  const grouped = (0, groupBy_1.default)(fkColumns.filter(DatabaseAnalyser.byTableFilter(table)), 'constraintName');
364
- return Object.keys(grouped).map(constraintName => (Object.assign(Object.assign({ constraintName, constraintType: 'foreignKey' }, (0, pick_1.default)(grouped[constraintName][0], [
365
- 'constraintName',
366
- 'schemaName',
367
- 'pureName',
368
- 'refSchemaName',
369
- 'refTableName',
370
- 'updateAction',
371
- 'deleteAction',
372
- ])), { columns: grouped[constraintName].map(fp_pick(['columnName', 'refColumnName'])) })));
352
+ return Object.keys(grouped).map(constraintName => ({
353
+ constraintName,
354
+ constraintType: 'foreignKey',
355
+ ...(0, pick_1.default)(grouped[constraintName][0], [
356
+ 'constraintName',
357
+ 'schemaName',
358
+ 'pureName',
359
+ 'refSchemaName',
360
+ 'refTableName',
361
+ 'updateAction',
362
+ 'deleteAction',
363
+ ]),
364
+ columns: grouped[constraintName].map(fp_pick(['columnName', 'refColumnName'])),
365
+ }));
373
366
  }
374
367
  }
375
368
  exports.DatabaseAnalyser = DatabaseAnalyser;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -179,104 +170,88 @@ class ScriptWriterEval {
179
170
  }
180
171
  endLine() { }
181
172
  requirePackage(packageName) { }
182
- assign(variableName, functionName, props) {
183
- return __awaiter(this, void 0, void 0, function* () {
184
- const func = (0, packageTools_1.evalShellApiFunctionName)(functionName, this.dbgateApi, this.requirePlugin);
185
- this.variables[variableName] = yield func((0, cloneDeepWith_1.default)(props, node => {
186
- if (node === null || node === void 0 ? void 0 : node.$hostConnection) {
187
- return this.hostConnection;
188
- }
189
- }));
190
- });
173
+ async assign(variableName, functionName, props) {
174
+ const func = (0, packageTools_1.evalShellApiFunctionName)(functionName, this.dbgateApi, this.requirePlugin);
175
+ this.variables[variableName] = await func((0, cloneDeepWith_1.default)(props, node => {
176
+ if (node === null || node === void 0 ? void 0 : node.$hostConnection) {
177
+ return this.hostConnection;
178
+ }
179
+ }));
191
180
  }
192
181
  assignValue(variableName, jsonValue) {
193
182
  this.variables[variableName] = jsonValue;
194
183
  }
195
- copyStream(sourceVar, targetVar, colmapVar = null, progressName) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- yield this.dbgateApi.copyStream(this.variables[sourceVar], this.variables[targetVar], {
198
- progressName: (0, cloneDeepWith_1.default)(progressName, node => {
184
+ async copyStream(sourceVar, targetVar, colmapVar = null, progressName) {
185
+ await this.dbgateApi.copyStream(this.variables[sourceVar], this.variables[targetVar], {
186
+ progressName: (0, cloneDeepWith_1.default)(progressName, node => {
187
+ if (node === null || node === void 0 ? void 0 : node.$runid) {
199
188
  if (node === null || node === void 0 ? void 0 : node.$runid) {
200
- if (node === null || node === void 0 ? void 0 : node.$runid) {
201
- return this.runid;
202
- }
189
+ return this.runid;
203
190
  }
204
- }),
205
- columns: colmapVar ? this.variables[colmapVar] : null,
206
- });
191
+ }
192
+ }),
193
+ columns: colmapVar ? this.variables[colmapVar] : null,
207
194
  });
208
195
  }
209
196
  comment(text) { }
210
- importDatabase(options) {
211
- return __awaiter(this, void 0, void 0, function* () {
212
- yield this.dbgateApi.importDatabase(options);
213
- });
197
+ async importDatabase(options) {
198
+ await this.dbgateApi.importDatabase(options);
214
199
  }
215
- dataReplicator(options) {
216
- return __awaiter(this, void 0, void 0, function* () {
217
- yield this.dbgateApi.dataReplicator(options);
218
- });
200
+ async dataReplicator(options) {
201
+ await this.dbgateApi.dataReplicator(options);
219
202
  }
220
- zipDirectory(inputDirectory, outputFile) {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- yield this.dbgateApi.zipDirectory(inputDirectory, outputFile);
223
- });
203
+ async zipDirectory(inputDirectory, outputFile) {
204
+ await this.dbgateApi.zipDirectory(inputDirectory, outputFile);
224
205
  }
225
206
  getScript(schedule) {
226
207
  throw new Error('Not implemented');
227
208
  }
228
209
  }
229
210
  exports.ScriptWriterEval = ScriptWriterEval;
230
- function playJsonCommand(cmd, script) {
231
- return __awaiter(this, void 0, void 0, function* () {
232
- switch (cmd.type) {
233
- case 'assign':
234
- yield script.assign(cmd.variableName, cmd.functionName, cmd.props);
235
- break;
236
- case 'assignValue':
237
- yield script.assignValue(cmd.variableName, cmd.jsonValue);
238
- break;
239
- case 'copyStream':
240
- yield script.copyStream(cmd.sourceVar, cmd.targetVar, cmd.colmapVar, cmd.progressName);
241
- break;
242
- case 'endLine':
243
- yield script.endLine();
244
- break;
245
- case 'comment':
246
- yield script.comment(cmd.text);
247
- break;
248
- case 'importDatabase':
249
- yield script.importDatabase(cmd.options);
250
- break;
251
- case 'dataReplicator':
252
- yield script.dataReplicator(cmd.options);
253
- break;
254
- case 'zipDirectory':
255
- yield script.zipDirectory(cmd.inputDirectory, cmd.outputFile);
256
- break;
257
- }
258
- });
211
+ async function playJsonCommand(cmd, script) {
212
+ switch (cmd.type) {
213
+ case 'assign':
214
+ await script.assign(cmd.variableName, cmd.functionName, cmd.props);
215
+ break;
216
+ case 'assignValue':
217
+ await script.assignValue(cmd.variableName, cmd.jsonValue);
218
+ break;
219
+ case 'copyStream':
220
+ await script.copyStream(cmd.sourceVar, cmd.targetVar, cmd.colmapVar, cmd.progressName);
221
+ break;
222
+ case 'endLine':
223
+ await script.endLine();
224
+ break;
225
+ case 'comment':
226
+ await script.comment(cmd.text);
227
+ break;
228
+ case 'importDatabase':
229
+ await script.importDatabase(cmd.options);
230
+ break;
231
+ case 'dataReplicator':
232
+ await script.dataReplicator(cmd.options);
233
+ break;
234
+ case 'zipDirectory':
235
+ await script.zipDirectory(cmd.inputDirectory, cmd.outputFile);
236
+ break;
237
+ }
259
238
  }
260
- function playJsonScriptWriter(json, script) {
261
- return __awaiter(this, void 0, void 0, function* () {
262
- for (const cmd of json.commands) {
263
- yield playJsonCommand(cmd, script);
264
- }
265
- });
239
+ async function playJsonScriptWriter(json, script) {
240
+ for (const cmd of json.commands) {
241
+ await playJsonCommand(cmd, script);
242
+ }
266
243
  }
267
244
  exports.playJsonScriptWriter = playJsonScriptWriter;
268
- function jsonScriptToJavascript(json) {
269
- return __awaiter(this, void 0, void 0, function* () {
270
- const { schedule, packageNames } = json;
271
- const script = new ScriptWriterJavaScript();
272
- for (const packageName of packageNames) {
273
- if (!/^dbgate-plugin-.*$/.test(packageName)) {
274
- throw new Error('Unallowed package name:' + packageName);
275
- }
276
- script.packageNames.push(packageName);
245
+ async function jsonScriptToJavascript(json) {
246
+ const { schedule, packageNames } = json;
247
+ const script = new ScriptWriterJavaScript();
248
+ for (const packageName of packageNames) {
249
+ if (!/^dbgate-plugin-.*$/.test(packageName)) {
250
+ throw new Error('Unallowed package name:' + packageName);
277
251
  }
278
- yield playJsonScriptWriter(json, script);
279
- return script.getScript(schedule);
280
- });
252
+ script.packageNames.push(packageName);
253
+ }
254
+ await playJsonScriptWriter(json, script);
255
+ return script.getScript(schedule);
281
256
  }
282
257
  exports.jsonScriptToJavascript = jsonScriptToJavascript;
package/lib/SqlDumper.js CHANGED
@@ -244,12 +244,12 @@ class SqlDumper {
244
244
  this.columnDefault(column);
245
245
  }
246
246
  if (includeNullable && !((_e = this.dialect) === null || _e === void 0 ? void 0 : _e.specificNullabilityImplementation)) {
247
- this.put(column.notNull ? '^not ^null' : '^null');
247
+ this.put(column.notNull ? '^not ^null' : this.dialect.implicitNullDeclaration ? '' : '^null');
248
248
  }
249
249
  }
250
250
  else {
251
251
  if (includeNullable && !((_f = this.dialect) === null || _f === void 0 ? void 0 : _f.specificNullabilityImplementation)) {
252
- this.put(column.notNull ? '^not ^null' : '^null');
252
+ this.put(column.notNull ? '^not ^null' : this.dialect.implicitNullDeclaration ? '' : '^null');
253
253
  }
254
254
  if (includeDefault && ((_h = (_g = column.defaultValue) === null || _g === void 0 ? void 0 : _g.toString()) === null || _h === void 0 ? void 0 : _h.trim())) {
255
255
  this.columnDefault(column);
@@ -608,21 +608,21 @@ class SqlDumper {
608
608
  if (autoinc) {
609
609
  this.allowIdentityInsert(newTable, true);
610
610
  }
611
- this.putCmd('^insert ^into %f (%,i) select %,i ^from %f', newTable, columnPairs.map(x => x.newcol.columnName), columnPairs.map(x => x.oldcol.columnName), Object.assign(Object.assign({}, oldTable), { pureName: tmpTable }));
611
+ this.putCmd('^insert ^into %f (%,i) select %,i ^from %f', newTable, columnPairs.map(x => x.newcol.columnName), columnPairs.map(x => x.oldcol.columnName), { ...oldTable, pureName: tmpTable });
612
612
  if (autoinc) {
613
613
  this.allowIdentityInsert(newTable, false);
614
614
  }
615
615
  if (this.dialect.dropForeignKey) {
616
616
  newTable.dependencies.forEach(cnt => this.createConstraint(cnt));
617
617
  }
618
- this.dropTable(Object.assign(Object.assign({}, oldTable), { pureName: tmpTable }));
618
+ this.dropTable({ ...oldTable, pureName: tmpTable });
619
619
  }
620
620
  else {
621
621
  // we have to preserve old table as long as possible
622
- this.createTable(Object.assign(Object.assign({}, newTable), { pureName: tmpTable }));
623
- this.putCmd('^insert ^into %f (%,i) select %,s ^from %f', Object.assign(Object.assign({}, newTable), { pureName: tmpTable }), columnPairs.map(x => x.newcol.columnName), columnPairs.map(x => x.oldcol.columnName), oldTable);
622
+ this.createTable({ ...newTable, pureName: tmpTable });
623
+ this.putCmd('^insert ^into %f (%,i) select %,s ^from %f', { ...newTable, pureName: tmpTable }, columnPairs.map(x => x.newcol.columnName), columnPairs.map(x => x.oldcol.columnName), oldTable);
624
624
  this.dropTable(oldTable);
625
- this.renameTable(Object.assign(Object.assign({}, newTable), { pureName: tmpTable }), newTable.pureName);
625
+ this.renameTable({ ...newTable, pureName: tmpTable }, newTable.pureName);
626
626
  }
627
627
  }
628
628
  createSqlObject(obj) {