knex 0.14.5 → 0.14.6
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/CHANGELOG.md +6 -0
- package/bin/cli.js +0 -0
- package/lib/client.js +4 -2
- package/lib/migrate/stub/coffee.stub +12 -12
- package/lib/migrate/stub/eg.stub +14 -14
- package/lib/migrate/stub/js.stub +15 -15
- package/lib/migrate/stub/knexfile-coffee.stub +34 -34
- package/lib/migrate/stub/knexfile-eg.stub +43 -43
- package/lib/migrate/stub/knexfile-js.stub +44 -44
- package/lib/migrate/stub/knexfile-ls.stub +35 -35
- package/lib/migrate/stub/ls.stub +14 -14
- package/package.json +1 -1
- package/scripts/release.sh +0 -0
- package/scripts/stress-test/README.txt +0 -0
- package/src/client.js +4 -2
- package/src/migrate/stub/coffee.stub +12 -12
- package/src/migrate/stub/eg.stub +14 -14
- package/src/migrate/stub/js.stub +15 -15
- package/src/migrate/stub/knexfile-coffee.stub +34 -34
- package/src/migrate/stub/knexfile-eg.stub +43 -43
- package/src/migrate/stub/knexfile-js.stub +44 -44
- package/src/migrate/stub/knexfile-ls.stub +35 -35
- package/src/migrate/stub/ls.stub +14 -14
- package/scripts/stress-test/debug.log +0 -0
- package/scripts/stress-test/mysql-not-recognizing-connection-drop.js +0 -61
package/CHANGELOG.md
CHANGED
package/bin/cli.js
CHANGED
|
File without changes
|
package/lib/client.js
CHANGED
|
@@ -191,7 +191,6 @@ function Client() {
|
|
|
191
191
|
var _this2 = this;
|
|
192
192
|
|
|
193
193
|
if (typeof obj === 'string') obj = { sql: obj };
|
|
194
|
-
obj.sql = this.positionBindings(obj.sql);
|
|
195
194
|
obj.bindings = this.prepBindings(obj.bindings);
|
|
196
195
|
|
|
197
196
|
var __knexUid = connection.__knexUid,
|
|
@@ -202,6 +201,8 @@ function Client() {
|
|
|
202
201
|
debugQuery(obj.sql, __knexTxId);
|
|
203
202
|
debugBindings(obj.bindings, __knexTxId);
|
|
204
203
|
|
|
204
|
+
obj.sql = this.positionBindings(obj.sql);
|
|
205
|
+
|
|
205
206
|
return this._query(connection, obj).catch(function (err) {
|
|
206
207
|
err.message = _this2._formatQuery(obj.sql, obj.bindings) + ' - ' + err.message;
|
|
207
208
|
_this2.emit('query-error', err, (0, _assign5.default)({ __knexUid: __knexUid, __knexTxId: __knexTxId }, obj));
|
|
@@ -210,7 +211,6 @@ function Client() {
|
|
|
210
211
|
},
|
|
211
212
|
stream: function stream(connection, obj, _stream, options) {
|
|
212
213
|
if (typeof obj === 'string') obj = { sql: obj };
|
|
213
|
-
obj.sql = this.positionBindings(obj.sql);
|
|
214
214
|
obj.bindings = this.prepBindings(obj.bindings);
|
|
215
215
|
|
|
216
216
|
var __knexUid = connection.__knexUid,
|
|
@@ -221,6 +221,8 @@ function Client() {
|
|
|
221
221
|
debugQuery(obj.sql, __knexTxId);
|
|
222
222
|
debugBindings(obj.bindings, __knexTxId);
|
|
223
223
|
|
|
224
|
+
obj.sql = this.positionBindings(obj.sql);
|
|
225
|
+
|
|
224
226
|
return this._stream(connection, obj, _stream, options);
|
|
225
227
|
},
|
|
226
228
|
prepBindings: function prepBindings(bindings) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
exports.up = (knex, Promise) ->
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
knex.schema.createTable "<%= d.tableName %>", (t) ->
|
|
5
|
-
t.increments()
|
|
6
|
-
t.timestamp()
|
|
7
|
-
<% } %>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.down = (knex, Promise) ->
|
|
11
|
-
<% if (d.tableName) { %>
|
|
12
|
-
knex.schema.dropTable "<%= d.tableName %>"
|
|
1
|
+
|
|
2
|
+
exports.up = (knex, Promise) ->
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
knex.schema.createTable "<%= d.tableName %>", (t) ->
|
|
5
|
+
t.increments()
|
|
6
|
+
t.timestamp()
|
|
7
|
+
<% } %>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.down = (knex, Promise) ->
|
|
11
|
+
<% if (d.tableName) { %>
|
|
12
|
+
knex.schema.dropTable "<%= d.tableName %>"
|
|
13
13
|
<% } %>
|
package/lib/migrate/stub/eg.stub
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
provide: up, down
|
|
2
|
-
|
|
3
|
-
up = (knex, Promise) ->
|
|
4
|
-
<% if (d.tableName) { %>
|
|
5
|
-
knex.schema.createTable "<%= d.tableName %>": t ->
|
|
6
|
-
t.increments()
|
|
7
|
-
t.timestamp()
|
|
8
|
-
<% } %>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
down = (knex, Promise) ->
|
|
12
|
-
<% if (d.tableName) { %>
|
|
13
|
-
knex.schema.dropTable("<%= d.tableName %>")
|
|
14
|
-
<% } %>
|
|
1
|
+
provide: up, down
|
|
2
|
+
|
|
3
|
+
up = (knex, Promise) ->
|
|
4
|
+
<% if (d.tableName) { %>
|
|
5
|
+
knex.schema.createTable "<%= d.tableName %>": t ->
|
|
6
|
+
t.increments()
|
|
7
|
+
t.timestamp()
|
|
8
|
+
<% } %>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
down = (knex, Promise) ->
|
|
12
|
+
<% if (d.tableName) { %>
|
|
13
|
+
knex.schema.dropTable("<%= d.tableName %>")
|
|
14
|
+
<% } %>
|
package/lib/migrate/stub/js.stub
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
exports.up = function(knex, Promise) {
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
return knex.schema.createTable("<%= d.tableName %>", function(t) {
|
|
5
|
-
t.increments();
|
|
6
|
-
t.timestamp();
|
|
7
|
-
});
|
|
8
|
-
<% } %>
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
exports.down = function(knex, Promise) {
|
|
12
|
-
<% if (d.tableName) { %>
|
|
13
|
-
return knex.schema.dropTable("<%= d.tableName %>");
|
|
14
|
-
<% } %>
|
|
15
|
-
};
|
|
1
|
+
|
|
2
|
+
exports.up = function(knex, Promise) {
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
return knex.schema.createTable("<%= d.tableName %>", function(t) {
|
|
5
|
+
t.increments();
|
|
6
|
+
t.timestamp();
|
|
7
|
+
});
|
|
8
|
+
<% } %>
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.down = function(knex, Promise) {
|
|
12
|
+
<% if (d.tableName) { %>
|
|
13
|
+
return knex.schema.dropTable("<%= d.tableName %>");
|
|
14
|
+
<% } %>
|
|
15
|
+
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
# Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
development:
|
|
6
|
-
client: 'sqlite3'
|
|
7
|
-
connection:
|
|
8
|
-
filename: './dev.sqlite3'
|
|
9
|
-
migrations:
|
|
10
|
-
tableName: 'knex_migrations'
|
|
11
|
-
|
|
12
|
-
staging:
|
|
13
|
-
client: 'postgresql'
|
|
14
|
-
connection:
|
|
15
|
-
database: 'my_db'
|
|
16
|
-
user: 'username'
|
|
17
|
-
password: 'password'
|
|
18
|
-
pool:
|
|
19
|
-
min: 2
|
|
20
|
-
max: 10
|
|
21
|
-
migrations:
|
|
22
|
-
tableName: 'knex_migrations'
|
|
23
|
-
|
|
24
|
-
production:
|
|
25
|
-
client: 'postgresql'
|
|
26
|
-
connection:
|
|
27
|
-
database: 'my_db'
|
|
28
|
-
user: 'username'
|
|
29
|
-
password: 'password'
|
|
30
|
-
pool:
|
|
31
|
-
min: 2
|
|
32
|
-
max: 10
|
|
33
|
-
migrations:
|
|
34
|
-
tableName: 'knex_migrations'
|
|
1
|
+
# Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports =
|
|
4
|
+
|
|
5
|
+
development:
|
|
6
|
+
client: 'sqlite3'
|
|
7
|
+
connection:
|
|
8
|
+
filename: './dev.sqlite3'
|
|
9
|
+
migrations:
|
|
10
|
+
tableName: 'knex_migrations'
|
|
11
|
+
|
|
12
|
+
staging:
|
|
13
|
+
client: 'postgresql'
|
|
14
|
+
connection:
|
|
15
|
+
database: 'my_db'
|
|
16
|
+
user: 'username'
|
|
17
|
+
password: 'password'
|
|
18
|
+
pool:
|
|
19
|
+
min: 2
|
|
20
|
+
max: 10
|
|
21
|
+
migrations:
|
|
22
|
+
tableName: 'knex_migrations'
|
|
23
|
+
|
|
24
|
+
production:
|
|
25
|
+
client: 'postgresql'
|
|
26
|
+
connection:
|
|
27
|
+
database: 'my_db'
|
|
28
|
+
user: 'username'
|
|
29
|
+
password: 'password'
|
|
30
|
+
pool:
|
|
31
|
+
min: 2
|
|
32
|
+
max: 10
|
|
33
|
+
migrations:
|
|
34
|
+
tableName: 'knex_migrations'
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
;; Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
development = {
|
|
5
|
-
client = 'sqlite3'
|
|
6
|
-
connection = {
|
|
7
|
-
filename = './dev.sqlite3'
|
|
8
|
-
}
|
|
9
|
-
migrations = {
|
|
10
|
-
tableName = 'knex_migrations'
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
staging = {
|
|
14
|
-
client = 'postgresql'
|
|
15
|
-
connection = {
|
|
16
|
-
database = 'my_db'
|
|
17
|
-
user = 'username'
|
|
18
|
-
password = 'password'
|
|
19
|
-
}
|
|
20
|
-
pool = {
|
|
21
|
-
min = 2
|
|
22
|
-
max = 10
|
|
23
|
-
}
|
|
24
|
-
migrations = {
|
|
25
|
-
tableName = 'knex_migrations'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
production = {
|
|
29
|
-
client = 'postgresql'
|
|
30
|
-
connection = {
|
|
31
|
-
database = 'my_db'
|
|
32
|
-
user = 'username'
|
|
33
|
-
password = 'password'
|
|
34
|
-
}
|
|
35
|
-
pool = {
|
|
36
|
-
min = 2
|
|
37
|
-
max = 10
|
|
38
|
-
}
|
|
39
|
-
migrations = {
|
|
40
|
-
tableName = 'knex_migrations'
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
;; Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
development = {
|
|
5
|
+
client = 'sqlite3'
|
|
6
|
+
connection = {
|
|
7
|
+
filename = './dev.sqlite3'
|
|
8
|
+
}
|
|
9
|
+
migrations = {
|
|
10
|
+
tableName = 'knex_migrations'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
staging = {
|
|
14
|
+
client = 'postgresql'
|
|
15
|
+
connection = {
|
|
16
|
+
database = 'my_db'
|
|
17
|
+
user = 'username'
|
|
18
|
+
password = 'password'
|
|
19
|
+
}
|
|
20
|
+
pool = {
|
|
21
|
+
min = 2
|
|
22
|
+
max = 10
|
|
23
|
+
}
|
|
24
|
+
migrations = {
|
|
25
|
+
tableName = 'knex_migrations'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
production = {
|
|
29
|
+
client = 'postgresql'
|
|
30
|
+
connection = {
|
|
31
|
+
database = 'my_db'
|
|
32
|
+
user = 'username'
|
|
33
|
+
password = 'password'
|
|
34
|
+
}
|
|
35
|
+
pool = {
|
|
36
|
+
min = 2
|
|
37
|
+
max = 10
|
|
38
|
+
}
|
|
39
|
+
migrations = {
|
|
40
|
+
tableName = 'knex_migrations'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
// Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
|
|
5
|
-
development: {
|
|
6
|
-
client: 'sqlite3',
|
|
7
|
-
connection: {
|
|
8
|
-
filename: './dev.sqlite3'
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
staging: {
|
|
13
|
-
client: 'postgresql',
|
|
14
|
-
connection: {
|
|
15
|
-
database: 'my_db',
|
|
16
|
-
user: 'username',
|
|
17
|
-
password: 'password'
|
|
18
|
-
},
|
|
19
|
-
pool: {
|
|
20
|
-
min: 2,
|
|
21
|
-
max: 10
|
|
22
|
-
},
|
|
23
|
-
migrations: {
|
|
24
|
-
tableName: 'knex_migrations'
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
production: {
|
|
29
|
-
client: 'postgresql',
|
|
30
|
-
connection: {
|
|
31
|
-
database: 'my_db',
|
|
32
|
-
user: 'username',
|
|
33
|
-
password: 'password'
|
|
34
|
-
},
|
|
35
|
-
pool: {
|
|
36
|
-
min: 2,
|
|
37
|
-
max: 10
|
|
38
|
-
},
|
|
39
|
-
migrations: {
|
|
40
|
-
tableName: 'knex_migrations'
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
};
|
|
1
|
+
// Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
|
|
5
|
+
development: {
|
|
6
|
+
client: 'sqlite3',
|
|
7
|
+
connection: {
|
|
8
|
+
filename: './dev.sqlite3'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
staging: {
|
|
13
|
+
client: 'postgresql',
|
|
14
|
+
connection: {
|
|
15
|
+
database: 'my_db',
|
|
16
|
+
user: 'username',
|
|
17
|
+
password: 'password'
|
|
18
|
+
},
|
|
19
|
+
pool: {
|
|
20
|
+
min: 2,
|
|
21
|
+
max: 10
|
|
22
|
+
},
|
|
23
|
+
migrations: {
|
|
24
|
+
tableName: 'knex_migrations'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
production: {
|
|
29
|
+
client: 'postgresql',
|
|
30
|
+
connection: {
|
|
31
|
+
database: 'my_db',
|
|
32
|
+
user: 'username',
|
|
33
|
+
password: 'password'
|
|
34
|
+
},
|
|
35
|
+
pool: {
|
|
36
|
+
min: 2,
|
|
37
|
+
max: 10
|
|
38
|
+
},
|
|
39
|
+
migrations: {
|
|
40
|
+
tableName: 'knex_migrations'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
development:
|
|
6
|
-
client: 'sqlite3'
|
|
7
|
-
connection:
|
|
8
|
-
filename: './dev.sqlite3'
|
|
9
|
-
migrations:
|
|
10
|
-
tableName: 'knex_migrations'
|
|
11
|
-
|
|
12
|
-
staging:
|
|
13
|
-
client: 'postgresql'
|
|
14
|
-
connection:
|
|
15
|
-
database: 'my_db'
|
|
16
|
-
user: 'username'
|
|
17
|
-
password: 'password'
|
|
18
|
-
pool:
|
|
19
|
-
min: 2
|
|
20
|
-
max: 10
|
|
21
|
-
migrations:
|
|
22
|
-
tableName: 'knex_migrations'
|
|
23
|
-
|
|
24
|
-
production:
|
|
25
|
-
client: 'postgresql'
|
|
26
|
-
connection:
|
|
27
|
-
database: 'my_db'
|
|
28
|
-
user: 'username'
|
|
29
|
-
password: 'password'
|
|
30
|
-
pool:
|
|
31
|
-
min: 2
|
|
32
|
-
max: 10
|
|
33
|
-
migrations:
|
|
34
|
-
tableName: 'knex_migrations'
|
|
35
|
-
|
|
1
|
+
# Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports =
|
|
4
|
+
|
|
5
|
+
development:
|
|
6
|
+
client: 'sqlite3'
|
|
7
|
+
connection:
|
|
8
|
+
filename: './dev.sqlite3'
|
|
9
|
+
migrations:
|
|
10
|
+
tableName: 'knex_migrations'
|
|
11
|
+
|
|
12
|
+
staging:
|
|
13
|
+
client: 'postgresql'
|
|
14
|
+
connection:
|
|
15
|
+
database: 'my_db'
|
|
16
|
+
user: 'username'
|
|
17
|
+
password: 'password'
|
|
18
|
+
pool:
|
|
19
|
+
min: 2
|
|
20
|
+
max: 10
|
|
21
|
+
migrations:
|
|
22
|
+
tableName: 'knex_migrations'
|
|
23
|
+
|
|
24
|
+
production:
|
|
25
|
+
client: 'postgresql'
|
|
26
|
+
connection:
|
|
27
|
+
database: 'my_db'
|
|
28
|
+
user: 'username'
|
|
29
|
+
password: 'password'
|
|
30
|
+
pool:
|
|
31
|
+
min: 2
|
|
32
|
+
max: 10
|
|
33
|
+
migrations:
|
|
34
|
+
tableName: 'knex_migrations'
|
|
35
|
+
|
package/lib/migrate/stub/ls.stub
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
exports.up = (knex, Promise) ->
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
knex.schema.create-table "<%= d.tableName %>", (t) ->
|
|
5
|
-
t.increments!
|
|
6
|
-
t.timestamp!
|
|
7
|
-
<% } %>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.down = (knex, Promise) ->
|
|
11
|
-
<% if (d.tableName) { %>
|
|
12
|
-
knex.schema.drop-table "<%= d.tableName %>"
|
|
13
|
-
<% } %>
|
|
14
|
-
|
|
1
|
+
|
|
2
|
+
exports.up = (knex, Promise) ->
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
knex.schema.create-table "<%= d.tableName %>", (t) ->
|
|
5
|
+
t.increments!
|
|
6
|
+
t.timestamp!
|
|
7
|
+
<% } %>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.down = (knex, Promise) ->
|
|
11
|
+
<% if (d.tableName) { %>
|
|
12
|
+
knex.schema.drop-table "<%= d.tableName %>"
|
|
13
|
+
<% } %>
|
|
14
|
+
|
package/package.json
CHANGED
package/scripts/release.sh
CHANGED
|
File without changes
|
|
File without changes
|
package/src/client.js
CHANGED
|
@@ -126,7 +126,6 @@ assign(Client.prototype, {
|
|
|
126
126
|
|
|
127
127
|
query(connection, obj) {
|
|
128
128
|
if (typeof obj === 'string') obj = {sql: obj}
|
|
129
|
-
obj.sql = this.positionBindings(obj.sql);
|
|
130
129
|
obj.bindings = this.prepBindings(obj.bindings)
|
|
131
130
|
|
|
132
131
|
const {__knexUid, __knexTxId} = connection;
|
|
@@ -135,6 +134,8 @@ assign(Client.prototype, {
|
|
|
135
134
|
debugQuery(obj.sql, __knexTxId)
|
|
136
135
|
debugBindings(obj.bindings, __knexTxId)
|
|
137
136
|
|
|
137
|
+
obj.sql = this.positionBindings(obj.sql);
|
|
138
|
+
|
|
138
139
|
return this._query(connection, obj).catch((err) => {
|
|
139
140
|
err.message = this._formatQuery(obj.sql, obj.bindings) + ' - ' + err.message
|
|
140
141
|
this.emit('query-error', err, assign({__knexUid, __knexTxId}, obj))
|
|
@@ -144,7 +145,6 @@ assign(Client.prototype, {
|
|
|
144
145
|
|
|
145
146
|
stream(connection, obj, stream, options) {
|
|
146
147
|
if (typeof obj === 'string') obj = {sql: obj}
|
|
147
|
-
obj.sql = this.positionBindings(obj.sql);
|
|
148
148
|
obj.bindings = this.prepBindings(obj.bindings)
|
|
149
149
|
|
|
150
150
|
const {__knexUid, __knexTxId} = connection;
|
|
@@ -153,6 +153,8 @@ assign(Client.prototype, {
|
|
|
153
153
|
debugQuery(obj.sql, __knexTxId)
|
|
154
154
|
debugBindings(obj.bindings, __knexTxId)
|
|
155
155
|
|
|
156
|
+
obj.sql = this.positionBindings(obj.sql);
|
|
157
|
+
|
|
156
158
|
return this._stream(connection, obj, stream, options)
|
|
157
159
|
},
|
|
158
160
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
exports.up = (knex, Promise) ->
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
knex.schema.createTable "<%= d.tableName %>", (t) ->
|
|
5
|
-
t.increments()
|
|
6
|
-
t.timestamp()
|
|
7
|
-
<% } %>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.down = (knex, Promise) ->
|
|
11
|
-
<% if (d.tableName) { %>
|
|
12
|
-
knex.schema.dropTable "<%= d.tableName %>"
|
|
1
|
+
|
|
2
|
+
exports.up = (knex, Promise) ->
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
knex.schema.createTable "<%= d.tableName %>", (t) ->
|
|
5
|
+
t.increments()
|
|
6
|
+
t.timestamp()
|
|
7
|
+
<% } %>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.down = (knex, Promise) ->
|
|
11
|
+
<% if (d.tableName) { %>
|
|
12
|
+
knex.schema.dropTable "<%= d.tableName %>"
|
|
13
13
|
<% } %>
|
package/src/migrate/stub/eg.stub
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
provide: up, down
|
|
2
|
-
|
|
3
|
-
up = (knex, Promise) ->
|
|
4
|
-
<% if (d.tableName) { %>
|
|
5
|
-
knex.schema.createTable "<%= d.tableName %>": t ->
|
|
6
|
-
t.increments()
|
|
7
|
-
t.timestamp()
|
|
8
|
-
<% } %>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
down = (knex, Promise) ->
|
|
12
|
-
<% if (d.tableName) { %>
|
|
13
|
-
knex.schema.dropTable("<%= d.tableName %>")
|
|
14
|
-
<% } %>
|
|
1
|
+
provide: up, down
|
|
2
|
+
|
|
3
|
+
up = (knex, Promise) ->
|
|
4
|
+
<% if (d.tableName) { %>
|
|
5
|
+
knex.schema.createTable "<%= d.tableName %>": t ->
|
|
6
|
+
t.increments()
|
|
7
|
+
t.timestamp()
|
|
8
|
+
<% } %>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
down = (knex, Promise) ->
|
|
12
|
+
<% if (d.tableName) { %>
|
|
13
|
+
knex.schema.dropTable("<%= d.tableName %>")
|
|
14
|
+
<% } %>
|
package/src/migrate/stub/js.stub
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
exports.up = function(knex, Promise) {
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
return knex.schema.createTable("<%= d.tableName %>", function(t) {
|
|
5
|
-
t.increments();
|
|
6
|
-
t.timestamp();
|
|
7
|
-
});
|
|
8
|
-
<% } %>
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
exports.down = function(knex, Promise) {
|
|
12
|
-
<% if (d.tableName) { %>
|
|
13
|
-
return knex.schema.dropTable("<%= d.tableName %>");
|
|
14
|
-
<% } %>
|
|
15
|
-
};
|
|
1
|
+
|
|
2
|
+
exports.up = function(knex, Promise) {
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
return knex.schema.createTable("<%= d.tableName %>", function(t) {
|
|
5
|
+
t.increments();
|
|
6
|
+
t.timestamp();
|
|
7
|
+
});
|
|
8
|
+
<% } %>
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.down = function(knex, Promise) {
|
|
12
|
+
<% if (d.tableName) { %>
|
|
13
|
+
return knex.schema.dropTable("<%= d.tableName %>");
|
|
14
|
+
<% } %>
|
|
15
|
+
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
# Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
development:
|
|
6
|
-
client: 'sqlite3'
|
|
7
|
-
connection:
|
|
8
|
-
filename: './dev.sqlite3'
|
|
9
|
-
migrations:
|
|
10
|
-
tableName: 'knex_migrations'
|
|
11
|
-
|
|
12
|
-
staging:
|
|
13
|
-
client: 'postgresql'
|
|
14
|
-
connection:
|
|
15
|
-
database: 'my_db'
|
|
16
|
-
user: 'username'
|
|
17
|
-
password: 'password'
|
|
18
|
-
pool:
|
|
19
|
-
min: 2
|
|
20
|
-
max: 10
|
|
21
|
-
migrations:
|
|
22
|
-
tableName: 'knex_migrations'
|
|
23
|
-
|
|
24
|
-
production:
|
|
25
|
-
client: 'postgresql'
|
|
26
|
-
connection:
|
|
27
|
-
database: 'my_db'
|
|
28
|
-
user: 'username'
|
|
29
|
-
password: 'password'
|
|
30
|
-
pool:
|
|
31
|
-
min: 2
|
|
32
|
-
max: 10
|
|
33
|
-
migrations:
|
|
34
|
-
tableName: 'knex_migrations'
|
|
1
|
+
# Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports =
|
|
4
|
+
|
|
5
|
+
development:
|
|
6
|
+
client: 'sqlite3'
|
|
7
|
+
connection:
|
|
8
|
+
filename: './dev.sqlite3'
|
|
9
|
+
migrations:
|
|
10
|
+
tableName: 'knex_migrations'
|
|
11
|
+
|
|
12
|
+
staging:
|
|
13
|
+
client: 'postgresql'
|
|
14
|
+
connection:
|
|
15
|
+
database: 'my_db'
|
|
16
|
+
user: 'username'
|
|
17
|
+
password: 'password'
|
|
18
|
+
pool:
|
|
19
|
+
min: 2
|
|
20
|
+
max: 10
|
|
21
|
+
migrations:
|
|
22
|
+
tableName: 'knex_migrations'
|
|
23
|
+
|
|
24
|
+
production:
|
|
25
|
+
client: 'postgresql'
|
|
26
|
+
connection:
|
|
27
|
+
database: 'my_db'
|
|
28
|
+
user: 'username'
|
|
29
|
+
password: 'password'
|
|
30
|
+
pool:
|
|
31
|
+
min: 2
|
|
32
|
+
max: 10
|
|
33
|
+
migrations:
|
|
34
|
+
tableName: 'knex_migrations'
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
;; Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
development = {
|
|
5
|
-
client = 'sqlite3'
|
|
6
|
-
connection = {
|
|
7
|
-
filename = './dev.sqlite3'
|
|
8
|
-
}
|
|
9
|
-
migrations = {
|
|
10
|
-
tableName = 'knex_migrations'
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
staging = {
|
|
14
|
-
client = 'postgresql'
|
|
15
|
-
connection = {
|
|
16
|
-
database = 'my_db'
|
|
17
|
-
user = 'username'
|
|
18
|
-
password = 'password'
|
|
19
|
-
}
|
|
20
|
-
pool = {
|
|
21
|
-
min = 2
|
|
22
|
-
max = 10
|
|
23
|
-
}
|
|
24
|
-
migrations = {
|
|
25
|
-
tableName = 'knex_migrations'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
production = {
|
|
29
|
-
client = 'postgresql'
|
|
30
|
-
connection = {
|
|
31
|
-
database = 'my_db'
|
|
32
|
-
user = 'username'
|
|
33
|
-
password = 'password'
|
|
34
|
-
}
|
|
35
|
-
pool = {
|
|
36
|
-
min = 2
|
|
37
|
-
max = 10
|
|
38
|
-
}
|
|
39
|
-
migrations = {
|
|
40
|
-
tableName = 'knex_migrations'
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
;; Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
development = {
|
|
5
|
+
client = 'sqlite3'
|
|
6
|
+
connection = {
|
|
7
|
+
filename = './dev.sqlite3'
|
|
8
|
+
}
|
|
9
|
+
migrations = {
|
|
10
|
+
tableName = 'knex_migrations'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
staging = {
|
|
14
|
+
client = 'postgresql'
|
|
15
|
+
connection = {
|
|
16
|
+
database = 'my_db'
|
|
17
|
+
user = 'username'
|
|
18
|
+
password = 'password'
|
|
19
|
+
}
|
|
20
|
+
pool = {
|
|
21
|
+
min = 2
|
|
22
|
+
max = 10
|
|
23
|
+
}
|
|
24
|
+
migrations = {
|
|
25
|
+
tableName = 'knex_migrations'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
production = {
|
|
29
|
+
client = 'postgresql'
|
|
30
|
+
connection = {
|
|
31
|
+
database = 'my_db'
|
|
32
|
+
user = 'username'
|
|
33
|
+
password = 'password'
|
|
34
|
+
}
|
|
35
|
+
pool = {
|
|
36
|
+
min = 2
|
|
37
|
+
max = 10
|
|
38
|
+
}
|
|
39
|
+
migrations = {
|
|
40
|
+
tableName = 'knex_migrations'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
// Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
|
|
5
|
-
development: {
|
|
6
|
-
client: 'sqlite3',
|
|
7
|
-
connection: {
|
|
8
|
-
filename: './dev.sqlite3'
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
staging: {
|
|
13
|
-
client: 'postgresql',
|
|
14
|
-
connection: {
|
|
15
|
-
database: 'my_db',
|
|
16
|
-
user: 'username',
|
|
17
|
-
password: 'password'
|
|
18
|
-
},
|
|
19
|
-
pool: {
|
|
20
|
-
min: 2,
|
|
21
|
-
max: 10
|
|
22
|
-
},
|
|
23
|
-
migrations: {
|
|
24
|
-
tableName: 'knex_migrations'
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
production: {
|
|
29
|
-
client: 'postgresql',
|
|
30
|
-
connection: {
|
|
31
|
-
database: 'my_db',
|
|
32
|
-
user: 'username',
|
|
33
|
-
password: 'password'
|
|
34
|
-
},
|
|
35
|
-
pool: {
|
|
36
|
-
min: 2,
|
|
37
|
-
max: 10
|
|
38
|
-
},
|
|
39
|
-
migrations: {
|
|
40
|
-
tableName: 'knex_migrations'
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
};
|
|
1
|
+
// Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
|
|
5
|
+
development: {
|
|
6
|
+
client: 'sqlite3',
|
|
7
|
+
connection: {
|
|
8
|
+
filename: './dev.sqlite3'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
staging: {
|
|
13
|
+
client: 'postgresql',
|
|
14
|
+
connection: {
|
|
15
|
+
database: 'my_db',
|
|
16
|
+
user: 'username',
|
|
17
|
+
password: 'password'
|
|
18
|
+
},
|
|
19
|
+
pool: {
|
|
20
|
+
min: 2,
|
|
21
|
+
max: 10
|
|
22
|
+
},
|
|
23
|
+
migrations: {
|
|
24
|
+
tableName: 'knex_migrations'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
production: {
|
|
29
|
+
client: 'postgresql',
|
|
30
|
+
connection: {
|
|
31
|
+
database: 'my_db',
|
|
32
|
+
user: 'username',
|
|
33
|
+
password: 'password'
|
|
34
|
+
},
|
|
35
|
+
pool: {
|
|
36
|
+
min: 2,
|
|
37
|
+
max: 10
|
|
38
|
+
},
|
|
39
|
+
migrations: {
|
|
40
|
+
tableName: 'knex_migrations'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# Update with your config settings.
|
|
2
|
-
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
development:
|
|
6
|
-
client: 'sqlite3'
|
|
7
|
-
connection:
|
|
8
|
-
filename: './dev.sqlite3'
|
|
9
|
-
migrations:
|
|
10
|
-
tableName: 'knex_migrations'
|
|
11
|
-
|
|
12
|
-
staging:
|
|
13
|
-
client: 'postgresql'
|
|
14
|
-
connection:
|
|
15
|
-
database: 'my_db'
|
|
16
|
-
user: 'username'
|
|
17
|
-
password: 'password'
|
|
18
|
-
pool:
|
|
19
|
-
min: 2
|
|
20
|
-
max: 10
|
|
21
|
-
migrations:
|
|
22
|
-
tableName: 'knex_migrations'
|
|
23
|
-
|
|
24
|
-
production:
|
|
25
|
-
client: 'postgresql'
|
|
26
|
-
connection:
|
|
27
|
-
database: 'my_db'
|
|
28
|
-
user: 'username'
|
|
29
|
-
password: 'password'
|
|
30
|
-
pool:
|
|
31
|
-
min: 2
|
|
32
|
-
max: 10
|
|
33
|
-
migrations:
|
|
34
|
-
tableName: 'knex_migrations'
|
|
35
|
-
|
|
1
|
+
# Update with your config settings.
|
|
2
|
+
|
|
3
|
+
module.exports =
|
|
4
|
+
|
|
5
|
+
development:
|
|
6
|
+
client: 'sqlite3'
|
|
7
|
+
connection:
|
|
8
|
+
filename: './dev.sqlite3'
|
|
9
|
+
migrations:
|
|
10
|
+
tableName: 'knex_migrations'
|
|
11
|
+
|
|
12
|
+
staging:
|
|
13
|
+
client: 'postgresql'
|
|
14
|
+
connection:
|
|
15
|
+
database: 'my_db'
|
|
16
|
+
user: 'username'
|
|
17
|
+
password: 'password'
|
|
18
|
+
pool:
|
|
19
|
+
min: 2
|
|
20
|
+
max: 10
|
|
21
|
+
migrations:
|
|
22
|
+
tableName: 'knex_migrations'
|
|
23
|
+
|
|
24
|
+
production:
|
|
25
|
+
client: 'postgresql'
|
|
26
|
+
connection:
|
|
27
|
+
database: 'my_db'
|
|
28
|
+
user: 'username'
|
|
29
|
+
password: 'password'
|
|
30
|
+
pool:
|
|
31
|
+
min: 2
|
|
32
|
+
max: 10
|
|
33
|
+
migrations:
|
|
34
|
+
tableName: 'knex_migrations'
|
|
35
|
+
|
package/src/migrate/stub/ls.stub
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
exports.up = (knex, Promise) ->
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
knex.schema.create-table "<%= d.tableName %>", (t) ->
|
|
5
|
-
t.increments!
|
|
6
|
-
t.timestamp!
|
|
7
|
-
<% } %>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.down = (knex, Promise) ->
|
|
11
|
-
<% if (d.tableName) { %>
|
|
12
|
-
knex.schema.drop-table "<%= d.tableName %>"
|
|
13
|
-
<% } %>
|
|
14
|
-
|
|
1
|
+
|
|
2
|
+
exports.up = (knex, Promise) ->
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
knex.schema.create-table "<%= d.tableName %>", (t) ->
|
|
5
|
+
t.increments!
|
|
6
|
+
t.timestamp!
|
|
7
|
+
<% } %>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.down = (knex, Promise) ->
|
|
11
|
+
<% if (d.tableName) { %>
|
|
12
|
+
knex.schema.drop-table "<%= d.tableName %>"
|
|
13
|
+
<% } %>
|
|
14
|
+
|
|
File without changes
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const toxiproxy = require('toxiproxy-node-client');
|
|
2
|
-
const toxicli = new toxiproxy.Toxiproxy('http://localhost:8474');
|
|
3
|
-
const rp = require('request-promise-native');
|
|
4
|
-
const Bluebird = require('bluebird');
|
|
5
|
-
|
|
6
|
-
const knex = require('../../lib')({
|
|
7
|
-
client: 'mysql2',
|
|
8
|
-
connection: 'mysql://root:mysqlrootpassword@localhost:23306/?charset=utf8',
|
|
9
|
-
pool: {
|
|
10
|
-
min: 0,
|
|
11
|
-
max: 10,
|
|
12
|
-
idleTimeoutMillis: 100,
|
|
13
|
-
reapIntervalMillis: 100
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
async function main () {
|
|
18
|
-
await recreateProxy('mysql', 23306, 3306);
|
|
19
|
-
try {
|
|
20
|
-
console.log('select 1');
|
|
21
|
-
await knex.raw('select 1');
|
|
22
|
-
console.log('waiting 5 secs for pool to discard connection');
|
|
23
|
-
await Bluebird.delay(5000 * 1);
|
|
24
|
-
console.log('closing connection by proxy');
|
|
25
|
-
await recreateProxy('mysql', 23306, 3306); // cut connection router level
|
|
26
|
-
console.log('waiting again 5 secs just for fun');
|
|
27
|
-
await Bluebird.delay(5000 * 1);
|
|
28
|
-
console.log('select 1');
|
|
29
|
-
await knex.raw('select 1');
|
|
30
|
-
} catch (e) {
|
|
31
|
-
console.log(e);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
main().then(async () => {
|
|
36
|
-
console.log('Main ended with success');
|
|
37
|
-
await knex.destroy();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
process.on('unhandledRejection', (reason, p) => {
|
|
41
|
-
console.log('Unhandled Rejection at:', p, 'reason:', reason);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
process.on('uncaughtException', (err) => {
|
|
45
|
-
console.log('Unhandled Exception!', err);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
async function recreateProxy(serviceName, listenPort, proxyToPort) {
|
|
50
|
-
try {
|
|
51
|
-
await rp.delete({
|
|
52
|
-
url: `${toxicli.host}/proxies/${serviceName}`
|
|
53
|
-
});
|
|
54
|
-
} catch(err) {}
|
|
55
|
-
|
|
56
|
-
const proxy = await toxicli.createProxy({
|
|
57
|
-
name: serviceName,
|
|
58
|
-
listen: `0.0.0.0:${listenPort}`,
|
|
59
|
-
upstream: `${serviceName}:${proxyToPort}`
|
|
60
|
-
});
|
|
61
|
-
}
|