-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.js
More file actions
74 lines (64 loc) · 1.36 KB
/
index.js
File metadata and controls
74 lines (64 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'use strict';
const { Workflow } = require('@axiosleo/cli-tool');
const Hook = require('./src/hook');
const { Builder } = require('./src/builder');
const migration = require('./src/migration');
const {
QueryHandler,
QueryOperator,
QueryCondition,
Query
} = require('./src/operator');
const {
TransactionOperator,
TransactionHandler
} = require('./src/transaction');
const {
getClient,
createPool,
createClient,
createPromiseClient,
MySQLClient
} = require('./src/client');
const _runMigration = async (action, dir, options = {}) => {
const workflow = new Workflow(migration);
try {
await workflow.start({
task_key: 'migrate_logs',
action: action.toLowerCase(),
config: {
dir: dir
},
connection: {
host: options.host || 'localhost',
port: options.port || 3306,
user: options.user || 'root',
password: options.password || '',
database: options.database || ''
},
debug: options.debug
});
} catch (e) {
if (e.curr && e.curr.error) {
throw e.curr.error;
} else {
throw e;
}
}
};
module.exports = {
Hook,
Builder,
Query,
QueryHandler,
QueryOperator,
QueryCondition,
TransactionOperator,
TransactionHandler,
MySQLClient,
getClient,
createPool,
createClient,
createPromiseClient,
migrate: _runMigration
};