|
1 | | -const _ = require('lodash'); |
2 | | -const reApi = require('../reverse_engineering/api'); |
3 | | -const { createLogger } = require('../reverse_engineering/helpers/loggerHelper'); |
4 | | -const applyToInstanceHelper = require('./applyToInstanceHelper'); |
5 | | -const { |
6 | | - buildEntityLevelAlterScript, |
7 | | - buildContainerLevelAlterScript, |
8 | | - doesContainerLevelAlterScriptContainDropStatements, |
9 | | - doesEntityLevelAlterScriptContainDropStatements, |
10 | | -} = require('./alterScript/alterScriptBuilder'); |
| 1 | +const { generateScript } = require('./api/generateScript'); |
| 2 | +const { generateViewScript } = require('./api/generateViewScript'); |
| 3 | +const { generateContainerScript } = require('./api/generateContainerScript'); |
| 4 | +const { getDatabases } = require('./api/getDatabases'); |
| 5 | +const { applyToInstance } = require('./api/applyToInstance'); |
| 6 | +const { testConnection } = require('./api/testConnection'); |
| 7 | +const { isDropInStatements } = require('./api/isDropInStatements'); |
11 | 8 |
|
12 | 9 | module.exports = { |
13 | | - generateScript(data, logger, callback, app) { |
14 | | - try { |
15 | | - const script = buildEntityLevelAlterScript(data, app); |
16 | | - callback(null, script); |
17 | | - } catch (error) { |
18 | | - logger.log('error', { message: error.message, stack: error.stack }, 'PostgreSQL Forward-Engineering Error'); |
19 | | - |
20 | | - callback({ message: error.message, stack: error.stack }); |
21 | | - } |
22 | | - }, |
23 | | - |
24 | | - generateViewScript(data, logger, callback, app) { |
25 | | - callback(new Error('Forward-Engineering of delta model on view level is not supported')); |
26 | | - }, |
27 | | - |
28 | | - generateContainerScript(data, logger, callback, app) { |
29 | | - try { |
30 | | - const script = buildContainerLevelAlterScript(data, app); |
31 | | - callback(null, script); |
32 | | - } catch (error) { |
33 | | - logger.log('error', { message: error.message, stack: error.stack }, 'PostgreSQL Forward-Engineering Error'); |
34 | | - |
35 | | - callback({ message: error.message, stack: error.stack }); |
36 | | - } |
37 | | - }, |
38 | | - |
39 | | - getDatabases(connectionInfo, logger, callback, app) { |
40 | | - logger.progress({ message: 'Find all databases' }); |
41 | | - |
42 | | - reApi.getDatabases(connectionInfo, logger, callback, app); |
43 | | - }, |
44 | | - |
45 | | - applyToInstance(connectionInfo, logger, callback, app) { |
46 | | - logger.clear(); |
47 | | - logger.log( |
48 | | - 'info', |
49 | | - _.omit(connectionInfo, 'script', 'containerData'), |
50 | | - 'connectionInfo', |
51 | | - connectionInfo.hiddenKeys, |
52 | | - ); |
53 | | - |
54 | | - const postgresLogger = createLogger({ |
55 | | - title: 'Apply to instance', |
56 | | - hiddenKeys: connectionInfo.hiddenKeys, |
57 | | - logger, |
58 | | - }); |
59 | | - |
60 | | - applyToInstanceHelper.applyToInstance(connectionInfo, postgresLogger, app).then(callback, callback); |
61 | | - }, |
62 | | - |
63 | | - testConnection(connectionInfo, logger, callback, app) { |
64 | | - reApi.testConnection(connectionInfo, logger, callback, app).then(callback, callback); |
65 | | - }, |
66 | | - |
67 | | - isDropInStatements(data, logger, callback, app) { |
68 | | - try { |
69 | | - if (data.level === 'container') { |
70 | | - const containsDropStatements = doesContainerLevelAlterScriptContainDropStatements(data, app); |
71 | | - callback(null, containsDropStatements); |
72 | | - } else { |
73 | | - const containsDropStatements = doesEntityLevelAlterScriptContainDropStatements(data, app); |
74 | | - callback(null, containsDropStatements); |
75 | | - } |
76 | | - } catch (e) { |
77 | | - callback({ message: e.message, stack: e.stack }); |
78 | | - } |
79 | | - }, |
| 10 | + generateScript, |
| 11 | + generateViewScript, |
| 12 | + generateContainerScript, |
| 13 | + getDatabases, |
| 14 | + applyToInstance, |
| 15 | + testConnection, |
| 16 | + isDropInStatements, |
80 | 17 | }; |
0 commit comments