murmuration 1.0.18 → 1.0.19
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.
|
@@ -10,7 +10,7 @@ const { insertVersion, selectMaximumVersion } = require("../../table/migration")
|
|
|
10
10
|
const { first } = arrayUtilities,
|
|
11
11
|
{ whilst } = asynchronousUtilities;
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function applyMigrationsOperation(next, done, context) {
|
|
14
14
|
const { configuration, migrationsDirectoryPath } = context,
|
|
15
15
|
migrations = Migrations.fromMigrationsDirectoryPath(migrationsDirectoryPath),
|
|
16
16
|
{ log } = configuration;
|
|
@@ -23,16 +23,16 @@ function applyMigrationsCallback(next, done, context) {
|
|
|
23
23
|
migrations
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
whilst(
|
|
26
|
+
whilst(applyMigrationOperation, () => {
|
|
27
27
|
delete context.migrations;
|
|
28
28
|
|
|
29
29
|
done();
|
|
30
30
|
}, context);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
module.exports =
|
|
33
|
+
module.exports = applyMigrationsOperation;
|
|
34
34
|
|
|
35
|
-
function
|
|
35
|
+
function applyMigrationOperation(next, done, context) {
|
|
36
36
|
const { configuration } = context,
|
|
37
37
|
{ log } = configuration;
|
|
38
38
|
|
|
@@ -4,7 +4,7 @@ const transaction = require("../../transaction");
|
|
|
4
4
|
|
|
5
5
|
const { createTable, insertVersion, showLikeTables } = require("../../table/migration");
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function initialiseOperation(next, done, context) {
|
|
8
8
|
const { configuration } = context,
|
|
9
9
|
{ log } = configuration;
|
|
10
10
|
|
|
@@ -13,9 +13,9 @@ function initialiseCallback(next, done, context) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const operations = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
checkTablePresentOperatino,
|
|
17
|
+
createMissingTableOperation,
|
|
18
|
+
insertZeroVersionOperation
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
transaction(configuration, operations, (completed) => {
|
|
@@ -39,9 +39,9 @@ function initialiseCallback(next, done, context) {
|
|
|
39
39
|
}, context);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
module.exports =
|
|
42
|
+
module.exports = initialiseOperation;
|
|
43
43
|
|
|
44
|
-
function
|
|
44
|
+
function checkTablePresentOperatino(connection, abort, proceed, complete, context) {
|
|
45
45
|
const { configuration } = context,
|
|
46
46
|
{ migrationSQLMap } = configuration,
|
|
47
47
|
{ showLikeTablesMigrationSQL } = migrationSQLMap,
|
|
@@ -65,7 +65,7 @@ function checkTablePresent(connection, abort, proceed, complete, context) {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function
|
|
68
|
+
function createMissingTableOperation(connection, abort, proceed, complete, context) {
|
|
69
69
|
const { configuration } = context,
|
|
70
70
|
{ migrationSQLMap } = configuration,
|
|
71
71
|
{ createTableMigrationSQL } = migrationSQLMap,
|
|
@@ -81,7 +81,7 @@ function createMissingTable(connection, abort, proceed, complete, context) {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function
|
|
84
|
+
function insertZeroVersionOperation(connection, abort, proceed, complete, context) {
|
|
85
85
|
const { configuration } = context,
|
|
86
86
|
{ migrationSQLMap } = configuration,
|
|
87
87
|
{ insertVersionMigrationSQL } = migrationSQLMap,
|
package/bin/migrate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const initialiseOperation = require("./migrate/operation/initialise"),
|
|
4
|
+
applyMigrationsOperation = require("./migrate/operation/applyMigrations");
|
|
5
5
|
|
|
6
6
|
const { asynchronousUtilities } = require("necessary");
|
|
7
7
|
|
|
@@ -9,8 +9,8 @@ const { sequence } = asynchronousUtilities;
|
|
|
9
9
|
|
|
10
10
|
function migrate(configuration, migrationsDirectoryPath, callback) {
|
|
11
11
|
const callbacks = [
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
initialiseOperation,
|
|
13
|
+
applyMigrationsOperation
|
|
14
14
|
],
|
|
15
15
|
error = false, ///
|
|
16
16
|
context = {
|
package/bin/transaction.js
CHANGED
|
@@ -8,13 +8,7 @@ const { whilst, sequence } = asynchronousUtilities;
|
|
|
8
8
|
|
|
9
9
|
function transaction(configuration, operations, callback, context) {
|
|
10
10
|
const { Connection } = configuration,
|
|
11
|
-
completed = false
|
|
12
|
-
callbacks = [
|
|
13
|
-
beginTransactionCallback,
|
|
14
|
-
executeOperationsCallback,
|
|
15
|
-
commitTransactionCallback,
|
|
16
|
-
rollbackTransactionCallback
|
|
17
|
-
];
|
|
11
|
+
completed = false;
|
|
18
12
|
|
|
19
13
|
Connection.fromConfiguration(configuration, (error, connection) => {
|
|
20
14
|
if (error) {
|
|
@@ -33,7 +27,14 @@ function transaction(configuration, operations, callback, context) {
|
|
|
33
27
|
completed
|
|
34
28
|
});
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
operations = [ ///
|
|
31
|
+
beginTransactionOperation,
|
|
32
|
+
executeOperationsOperation,
|
|
33
|
+
commitTransactionOperation,
|
|
34
|
+
rollbackTransactionOperation
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
sequence(operations, () => {
|
|
37
38
|
const { completed } = context;
|
|
38
39
|
|
|
39
40
|
delete context.connection;
|
|
@@ -45,12 +46,11 @@ function transaction(configuration, operations, callback, context) {
|
|
|
45
46
|
callback(completed);
|
|
46
47
|
}, context);
|
|
47
48
|
});
|
|
48
|
-
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
module.exports = transaction;
|
|
52
52
|
|
|
53
|
-
function
|
|
53
|
+
function beginTransactionOperation(next, done, context) {
|
|
54
54
|
const { connection } = context,
|
|
55
55
|
log = connection.getLog();
|
|
56
56
|
|
|
@@ -71,7 +71,7 @@ function beginTransactionCallback(next, done, context) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function
|
|
74
|
+
function commitTransactionOperation(next, done, context) {
|
|
75
75
|
const { completed } = context;
|
|
76
76
|
|
|
77
77
|
if (!completed) {
|
|
@@ -100,7 +100,7 @@ function commitTransactionCallback(next, done, context) {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
function
|
|
103
|
+
function rollbackTransactionOperation(next, done, context) {
|
|
104
104
|
const { completed } = context;
|
|
105
105
|
|
|
106
106
|
if (completed) {
|
|
@@ -129,7 +129,7 @@ function rollbackTransactionCallback(next, done, context) {
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
function
|
|
132
|
+
function executeOperationsOperation(next, done, context) {
|
|
133
133
|
whilst(executeOperation, next, context);
|
|
134
134
|
}
|
|
135
135
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "murmuration",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.19",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/murmuration",
|
|
7
7
|
"description": "Database connections, transactions and migrations.",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "https://github.com/djalbat/murmuration"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"necessary": "^10.0.
|
|
13
|
+
"necessary": "^10.0.4"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {},
|
|
16
16
|
"scripts": {}
|