knex 0.21.20 → 0.21.21

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.
Files changed (141) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/CONTRIBUTING.md +184 -184
  3. package/LICENSE +22 -22
  4. package/README.md +95 -95
  5. package/bin/cli.js +414 -414
  6. package/bin/utils/cli-config-utils.js +151 -151
  7. package/bin/utils/constants.js +7 -7
  8. package/bin/utils/migrationsLister.js +37 -37
  9. package/knex.js +8 -8
  10. package/lib/client.js +413 -413
  11. package/lib/config-resolver.js +61 -61
  12. package/lib/constants.js +44 -44
  13. package/lib/dialects/mssql/index.js +390 -390
  14. package/lib/dialects/mssql/query/compiler.js +444 -444
  15. package/lib/dialects/mssql/schema/columncompiler.js +103 -103
  16. package/lib/dialects/mssql/schema/compiler.js +59 -59
  17. package/lib/dialects/mssql/schema/tablecompiler.js +245 -245
  18. package/lib/dialects/mssql/transaction.js +97 -97
  19. package/lib/dialects/mysql/index.js +191 -191
  20. package/lib/dialects/mysql/query/compiler.js +142 -142
  21. package/lib/dialects/mysql/schema/columncompiler.js +171 -171
  22. package/lib/dialects/mysql/schema/compiler.js +60 -60
  23. package/lib/dialects/mysql/schema/tablecompiler.js +262 -262
  24. package/lib/dialects/mysql/transaction.js +48 -48
  25. package/lib/dialects/mysql2/index.js +35 -35
  26. package/lib/dialects/mysql2/transaction.js +46 -46
  27. package/lib/dialects/oracle/DEAD_CODE.md +5 -5
  28. package/lib/dialects/oracle/formatter.js +20 -20
  29. package/lib/dialects/oracle/index.js +79 -79
  30. package/lib/dialects/oracle/query/compiler.js +327 -327
  31. package/lib/dialects/oracle/schema/columnbuilder.js +18 -18
  32. package/lib/dialects/oracle/schema/columncompiler.js +139 -139
  33. package/lib/dialects/oracle/schema/compiler.js +81 -81
  34. package/lib/dialects/oracle/schema/tablecompiler.js +165 -165
  35. package/lib/dialects/oracle/schema/trigger.js +126 -126
  36. package/lib/dialects/oracle/utils.js +86 -86
  37. package/lib/dialects/oracledb/index.js +489 -489
  38. package/lib/dialects/oracledb/query/compiler.js +363 -363
  39. package/lib/dialects/oracledb/schema/columncompiler.js +35 -35
  40. package/lib/dialects/oracledb/transaction.js +76 -76
  41. package/lib/dialects/oracledb/utils.js +14 -14
  42. package/lib/dialects/postgres/index.js +319 -319
  43. package/lib/dialects/postgres/query/compiler.js +206 -206
  44. package/lib/dialects/postgres/schema/columncompiler.js +125 -125
  45. package/lib/dialects/postgres/schema/compiler.js +109 -109
  46. package/lib/dialects/postgres/schema/tablecompiler.js +183 -183
  47. package/lib/dialects/redshift/index.js +73 -73
  48. package/lib/dialects/redshift/query/compiler.js +119 -119
  49. package/lib/dialects/redshift/schema/columnbuilder.js +20 -20
  50. package/lib/dialects/redshift/schema/columncompiler.js +60 -60
  51. package/lib/dialects/redshift/schema/compiler.js +14 -14
  52. package/lib/dialects/redshift/schema/tablecompiler.js +123 -123
  53. package/lib/dialects/redshift/transaction.js +18 -18
  54. package/lib/dialects/sqlite3/formatter.js +21 -21
  55. package/lib/dialects/sqlite3/index.js +169 -169
  56. package/lib/dialects/sqlite3/query/compiler.js +222 -222
  57. package/lib/dialects/sqlite3/schema/columncompiler.js +27 -27
  58. package/lib/dialects/sqlite3/schema/compiler.js +49 -49
  59. package/lib/dialects/sqlite3/schema/ddl.js +525 -525
  60. package/lib/dialects/sqlite3/schema/tablecompiler.js +238 -238
  61. package/lib/formatter.js +295 -295
  62. package/lib/functionhelper.js +14 -14
  63. package/lib/helpers.js +92 -92
  64. package/lib/index.js +3 -3
  65. package/lib/interface.js +115 -115
  66. package/lib/knex.js +42 -42
  67. package/lib/logger.js +76 -76
  68. package/lib/migrate/MigrationGenerator.js +82 -82
  69. package/lib/migrate/Migrator.js +611 -611
  70. package/lib/migrate/configuration-merger.js +60 -60
  71. package/lib/migrate/migrate-stub.js +17 -17
  72. package/lib/migrate/migration-list-resolver.js +36 -36
  73. package/lib/migrate/sources/fs-migrations.js +99 -99
  74. package/lib/migrate/stub/cjs.stub +15 -15
  75. package/lib/migrate/stub/coffee.stub +13 -13
  76. package/lib/migrate/stub/eg.stub +14 -14
  77. package/lib/migrate/stub/js.stub +15 -15
  78. package/lib/migrate/stub/knexfile-coffee.stub +34 -34
  79. package/lib/migrate/stub/knexfile-eg.stub +43 -43
  80. package/lib/migrate/stub/knexfile-js.stub +44 -44
  81. package/lib/migrate/stub/knexfile-ls.stub +35 -35
  82. package/lib/migrate/stub/knexfile-ts.stub +44 -44
  83. package/lib/migrate/stub/ls.stub +14 -14
  84. package/lib/migrate/stub/ts.stub +21 -21
  85. package/lib/migrate/table-creator.js +67 -67
  86. package/lib/migrate/table-resolver.js +27 -27
  87. package/lib/query/builder.js +1372 -1372
  88. package/lib/query/compiler.js +889 -889
  89. package/lib/query/constants.js +13 -13
  90. package/lib/query/joinclause.js +263 -263
  91. package/lib/query/methods.js +92 -92
  92. package/lib/query/string.js +190 -190
  93. package/lib/raw.js +188 -188
  94. package/lib/ref.js +39 -39
  95. package/lib/runner.js +285 -285
  96. package/lib/schema/builder.js +82 -82
  97. package/lib/schema/columnbuilder.js +117 -117
  98. package/lib/schema/columncompiler.js +177 -177
  99. package/lib/schema/compiler.js +101 -101
  100. package/lib/schema/helpers.js +51 -51
  101. package/lib/schema/tablebuilder.js +288 -288
  102. package/lib/schema/tablecompiler.js +296 -296
  103. package/lib/seed/Seeder.js +203 -203
  104. package/lib/seed/seed-stub.js +13 -13
  105. package/lib/seed/stub/coffee.stub +9 -9
  106. package/lib/seed/stub/eg.stub +11 -11
  107. package/lib/seed/stub/js.stub +13 -13
  108. package/lib/seed/stub/ls.stub +11 -11
  109. package/lib/seed/stub/ts.stub +13 -13
  110. package/lib/transaction.js +363 -363
  111. package/lib/util/batchInsert.js +59 -59
  112. package/lib/util/delay.js +6 -6
  113. package/lib/util/fake-client.js +9 -9
  114. package/lib/util/finally-mixin.js +13 -13
  115. package/lib/util/fs.js +76 -76
  116. package/lib/util/import-file.js +13 -13
  117. package/lib/util/is-module-type.js +14 -14
  118. package/lib/util/is.js +32 -32
  119. package/lib/util/make-knex.js +338 -338
  120. package/lib/util/nanoid.js +29 -29
  121. package/lib/util/noop.js +1 -1
  122. package/lib/util/parse-connection.js +66 -66
  123. package/lib/util/save-async-stack.js +14 -14
  124. package/lib/util/template.js +52 -52
  125. package/lib/util/timeout.js +29 -29
  126. package/lib/util/timestamp.js +16 -16
  127. package/package.json +1 -1
  128. package/scripts/build.js +125 -125
  129. package/scripts/docker-compose.yml +111 -111
  130. package/scripts/next-release-howto.md +24 -24
  131. package/scripts/release.sh +34 -34
  132. package/scripts/runkit-example.js +34 -34
  133. package/scripts/stress-test/README.txt +18 -18
  134. package/scripts/stress-test/docker-compose.yml +47 -47
  135. package/scripts/stress-test/knex-stress-test.js +196 -196
  136. package/scripts/stress-test/mysql2-random-hanging-every-now-and-then.js +145 -145
  137. package/scripts/stress-test/mysql2-sudden-exit-without-error.js +100 -100
  138. package/scripts/stress-test/reconnect-test-mysql-based-drivers.js +184 -184
  139. package/types/index.d.ts +2249 -2249
  140. package/types/result.d.ts +27 -27
  141. package/types/tables.d.ts +4 -4
package/scripts/build.js CHANGED
@@ -1,125 +1,125 @@
1
- #!/usr/bin/env node
2
- const fs = require('fs');
3
- const path = require('path');
4
- const child_process = require('child_process');
5
- const _ = require('lodash');
6
-
7
- const exec = function (cmd, args) {
8
- return new Promise(function (resolve, reject) {
9
- // Execute command
10
- const child = child_process.exec(cmd, {
11
- cwd: process.cwd(),
12
- env: process.env,
13
- });
14
-
15
- // Pass stdout and stderr
16
- child.stdout.on('data', function (data) {
17
- process.stdout.write(data.toString());
18
- });
19
- child.stderr.on('data', function (data) {
20
- process.stderr.write(data.toString());
21
- });
22
- // Handle result
23
- child.on('exit', function (code) {
24
- if (code) reject(code);
25
- else resolve();
26
- });
27
- child.on('error', reject);
28
- });
29
- };
30
-
31
- const CWD = process.cwd();
32
- const POSTINSTALL_BUILD_CWD = process.env.POSTINSTALL_BUILD_CWD;
33
-
34
- // If we didn't have this check, then we'd be stuck in an infinite `postinstall`
35
- // loop, since we run `npm install --only=dev` below, triggering another
36
- // `postinstall`. We can't use `--ignore-scripts` because that ignores scripts
37
- // on all the modules that get installed, too, which would break stuff. So
38
- // instead, we set an environment variable, `POSTINSTALL_BUILD_CWD`, that keeps
39
- // track of what we're installing. It's more than just a yes/no flag because
40
- // the dev dependencies we're installing might use `postinstall-build` too, and
41
- // we don't want the flag to prevent them from running.
42
- if (POSTINSTALL_BUILD_CWD !== CWD) {
43
- const BUILD_ARTIFACT = process.argv[2];
44
- const BUILD_COMMAND = process.argv[3];
45
-
46
- fs.stat(BUILD_ARTIFACT, function (err, stats) {
47
- if (err || !(stats.isFile() || stats.isDirectory())) {
48
- // This script will run again after we run `npm install` below. Set an
49
- // environment variable to tell it to skip the check. Really we just want
50
- // the execSync's `env` to be modified, but it's easier just modify and
51
- // pass along the entire `process.env`.
52
- process.env.POSTINSTALL_BUILD_CWD = CWD;
53
- // We already have prod dependencies, that's what triggered `postinstall`
54
- // in the first place. So only install dev.
55
-
56
- // Fetch package.json
57
- const pkgJson = require(path.join(CWD, 'package.json'));
58
- const devDeps = pkgJson.devDependencies;
59
- // Values listed under `buildDependencies` contain the dependency names
60
- // that are required for `lib` building.
61
- const buildDependencies = _.pick(devDeps, pkgJson.buildDependencies);
62
-
63
- // Proceed only if there is something to install
64
- if (!_.isEmpty(buildDependencies)) {
65
- const opts = { env: process.env, stdio: 'inherit' };
66
-
67
- console.log('Building Knex.js');
68
-
69
- // Map all key (dependency) value (semver) pairs to
70
- // "dependency@semver dependency@semver ..." string that can be used
71
- // for `npm install` command
72
- const installArgs = _(buildDependencies)
73
- .pickBy(function (semver, dep) {
74
- // Check if the dependency is already installed
75
- try {
76
- require(dep);
77
- return false;
78
- } catch (err) {
79
- return true;
80
- }
81
- })
82
- .map(function (semver, dep) {
83
- // Format installable dependencies
84
- return dep + '@' + semver;
85
- })
86
- .value()
87
- .join(' ');
88
- const needsDepInstallation = !_.isEmpty(installArgs);
89
- const dependenciesInstalledQ = needsDepInstallation
90
- ? exec('npm install ' + installArgs, opts)
91
- : Promise.resolve();
92
- dependenciesInstalledQ
93
- .then(function () {
94
- console.log('✓');
95
- // Don't need the flag anymore as `postinstall` was already run.
96
- // Change it back so the environment is minimally changed for the
97
- // remaining commands.
98
- process.env.POSTINSTALL_BUILD_CWD = POSTINSTALL_BUILD_CWD;
99
- console.log('Building compiled files (' + BUILD_COMMAND + ')');
100
- return exec(BUILD_COMMAND, opts);
101
- })
102
- .catch(function (err) {
103
- console.error(err);
104
- process.exit(1);
105
- })
106
- .then(function () {
107
- if (process.env.NODE_ENV === 'production') {
108
- console.log('✓');
109
- console.log('Pruning dev dependencies for production build');
110
- return exec('npm prune --production', opts);
111
- } else {
112
- console.log('Skipping npm prune');
113
- }
114
- })
115
- .then(function () {
116
- console.log('✓');
117
- })
118
- .catch(function (err) {
119
- console.error(err);
120
- process.exit(1);
121
- });
122
- }
123
- }
124
- });
125
- }
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const child_process = require('child_process');
5
+ const _ = require('lodash');
6
+
7
+ const exec = function (cmd, args) {
8
+ return new Promise(function (resolve, reject) {
9
+ // Execute command
10
+ const child = child_process.exec(cmd, {
11
+ cwd: process.cwd(),
12
+ env: process.env,
13
+ });
14
+
15
+ // Pass stdout and stderr
16
+ child.stdout.on('data', function (data) {
17
+ process.stdout.write(data.toString());
18
+ });
19
+ child.stderr.on('data', function (data) {
20
+ process.stderr.write(data.toString());
21
+ });
22
+ // Handle result
23
+ child.on('exit', function (code) {
24
+ if (code) reject(code);
25
+ else resolve();
26
+ });
27
+ child.on('error', reject);
28
+ });
29
+ };
30
+
31
+ const CWD = process.cwd();
32
+ const POSTINSTALL_BUILD_CWD = process.env.POSTINSTALL_BUILD_CWD;
33
+
34
+ // If we didn't have this check, then we'd be stuck in an infinite `postinstall`
35
+ // loop, since we run `npm install --only=dev` below, triggering another
36
+ // `postinstall`. We can't use `--ignore-scripts` because that ignores scripts
37
+ // on all the modules that get installed, too, which would break stuff. So
38
+ // instead, we set an environment variable, `POSTINSTALL_BUILD_CWD`, that keeps
39
+ // track of what we're installing. It's more than just a yes/no flag because
40
+ // the dev dependencies we're installing might use `postinstall-build` too, and
41
+ // we don't want the flag to prevent them from running.
42
+ if (POSTINSTALL_BUILD_CWD !== CWD) {
43
+ const BUILD_ARTIFACT = process.argv[2];
44
+ const BUILD_COMMAND = process.argv[3];
45
+
46
+ fs.stat(BUILD_ARTIFACT, function (err, stats) {
47
+ if (err || !(stats.isFile() || stats.isDirectory())) {
48
+ // This script will run again after we run `npm install` below. Set an
49
+ // environment variable to tell it to skip the check. Really we just want
50
+ // the execSync's `env` to be modified, but it's easier just modify and
51
+ // pass along the entire `process.env`.
52
+ process.env.POSTINSTALL_BUILD_CWD = CWD;
53
+ // We already have prod dependencies, that's what triggered `postinstall`
54
+ // in the first place. So only install dev.
55
+
56
+ // Fetch package.json
57
+ const pkgJson = require(path.join(CWD, 'package.json'));
58
+ const devDeps = pkgJson.devDependencies;
59
+ // Values listed under `buildDependencies` contain the dependency names
60
+ // that are required for `lib` building.
61
+ const buildDependencies = _.pick(devDeps, pkgJson.buildDependencies);
62
+
63
+ // Proceed only if there is something to install
64
+ if (!_.isEmpty(buildDependencies)) {
65
+ const opts = { env: process.env, stdio: 'inherit' };
66
+
67
+ console.log('Building Knex.js');
68
+
69
+ // Map all key (dependency) value (semver) pairs to
70
+ // "dependency@semver dependency@semver ..." string that can be used
71
+ // for `npm install` command
72
+ const installArgs = _(buildDependencies)
73
+ .pickBy(function (semver, dep) {
74
+ // Check if the dependency is already installed
75
+ try {
76
+ require(dep);
77
+ return false;
78
+ } catch (err) {
79
+ return true;
80
+ }
81
+ })
82
+ .map(function (semver, dep) {
83
+ // Format installable dependencies
84
+ return dep + '@' + semver;
85
+ })
86
+ .value()
87
+ .join(' ');
88
+ const needsDepInstallation = !_.isEmpty(installArgs);
89
+ const dependenciesInstalledQ = needsDepInstallation
90
+ ? exec('npm install ' + installArgs, opts)
91
+ : Promise.resolve();
92
+ dependenciesInstalledQ
93
+ .then(function () {
94
+ console.log('✓');
95
+ // Don't need the flag anymore as `postinstall` was already run.
96
+ // Change it back so the environment is minimally changed for the
97
+ // remaining commands.
98
+ process.env.POSTINSTALL_BUILD_CWD = POSTINSTALL_BUILD_CWD;
99
+ console.log('Building compiled files (' + BUILD_COMMAND + ')');
100
+ return exec(BUILD_COMMAND, opts);
101
+ })
102
+ .catch(function (err) {
103
+ console.error(err);
104
+ process.exit(1);
105
+ })
106
+ .then(function () {
107
+ if (process.env.NODE_ENV === 'production') {
108
+ console.log('✓');
109
+ console.log('Pruning dev dependencies for production build');
110
+ return exec('npm prune --production', opts);
111
+ } else {
112
+ console.log('Skipping npm prune');
113
+ }
114
+ })
115
+ .then(function () {
116
+ console.log('✓');
117
+ })
118
+ .catch(function (err) {
119
+ console.error(err);
120
+ process.exit(1);
121
+ });
122
+ }
123
+ }
124
+ });
125
+ }
@@ -1,111 +1,111 @@
1
- version: '3'
2
-
3
- services:
4
- mssql:
5
- image: mcr.microsoft.com/mssql/server:2017-latest
6
- ports:
7
- - '21433:1433'
8
- environment:
9
- - ACCEPT_EULA=Y
10
- - SA_PASSWORD=S0meVeryHardPassword
11
- healthcheck:
12
- test: /opt/mssql-tools/bin/sqlcmd -S mssql -U sa -P 'S0meVeryHardPassword' -Q 'select 1'
13
- waitmssql:
14
- image: mcr.microsoft.com/mssql/server:2017-latest
15
- links:
16
- - mssql
17
- depends_on:
18
- - mssql
19
- entrypoint:
20
- - bash
21
- - -c
22
- # https://docs.microsoft.com/en-us/sql/relational-databases/logs/control-transaction-durability?view=sql-server-ver15#bkmk_DbControl
23
- - 'until /opt/mssql-tools/bin/sqlcmd -S mssql -U sa -P S0meVeryHardPassword -d master -Q "CREATE DATABASE knex_test; ALTER DATABASE knex_test SET DELAYED_DURABILITY = FORCED"; do sleep 5; done'
24
-
25
- mysql:
26
- image: mysql
27
- # https://dev.mysql.com/doc/refman/8.0/en/mysql-acid.html
28
- # https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_flush_method
29
- # nosync only for unix, edit for local start on other systems
30
- command: --default-authentication-plugin=mysql_native_password --sync_binlog=0 --innodb_doublewrite=OFF --innodb-flush-log-at-trx-commit=0 --innodb-flush-method=nosync
31
- ports:
32
- - '23306:3306'
33
- environment:
34
- - MYSQL_ROOT_PASSWORD=testrootpassword
35
- - MYSQL_DATABASE=knex_test
36
- - MYSQL_USER=testuser
37
- - MYSQL_PASSWORD=testpassword
38
- healthcheck:
39
- test:
40
- [
41
- 'CMD',
42
- '/usr/bin/mysql',
43
- '-hlocalhost',
44
- '-utestuser',
45
- '-ptestpassword',
46
- '-e',
47
- 'SELECT 1',
48
- ]
49
- interval: 30s
50
- timeout: 5s
51
- retries: 3
52
- restart: always
53
- volumes:
54
- - mysql_data:/var/lib/mysql
55
- waitmysql:
56
- image: mysql
57
- links:
58
- - mysql
59
- depends_on:
60
- - mysql
61
- entrypoint:
62
- - bash
63
- - -c
64
- - 'until /usr/bin/mysql -hmysql -utestuser -ptestpassword -e "SELECT 1"; do sleep 5; done'
65
-
66
- postgres:
67
- image: postgres:alpine
68
- # see https://www.postgresql.org/docs/current/non-durability.html
69
- command: '-c full_page_writes=off -c fsync=off -c synchronous_commit=off'
70
- ports:
71
- - '25432:5432'
72
- environment:
73
- - POSTGRES_USER=testuser
74
- - POSTGRES_PASSWORD=knextest
75
- - POSTGRES_DB=knex_test
76
- waitpostgres:
77
- image: postgres:alpine
78
- links:
79
- - postgres
80
- depends_on:
81
- - postgres
82
- entrypoint:
83
- - bash
84
- - -c
85
- - 'until /usr/local/bin/psql postgres://testuser:knextest@postgres/knex_test -c "SELECT 1"; do sleep 5; done'
86
-
87
- oracledbxe:
88
- image: quillbuilduser/oracle-18-xe
89
- container_name: oracledbxe_container
90
- ports:
91
- - '21521:1521'
92
- environment:
93
- - ORACLE_ALLOW_REMOTE=true
94
- waitoracledbxe:
95
- image: quillbuilduser/oracle-18-xe
96
- links:
97
- - oracledbxe
98
- depends_on:
99
- - oracledbxe
100
- environment:
101
- - ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
102
- entrypoint:
103
- - bash
104
- - -c
105
- - 'until /opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s sys/Oracle18@oracledbxe/XE as sysdba <<< "SELECT 13376411 FROM DUAL; exit;" | grep "13376411"; do echo "Could not connect to oracle... sleep for a while"; sleep 5; done'
106
-
107
- volumes:
108
- mysql_data:
109
- driver_opts:
110
- type: tmpfs
111
- device: tmpfs
1
+ version: '3'
2
+
3
+ services:
4
+ mssql:
5
+ image: mcr.microsoft.com/mssql/server:2017-latest
6
+ ports:
7
+ - '21433:1433'
8
+ environment:
9
+ - ACCEPT_EULA=Y
10
+ - SA_PASSWORD=S0meVeryHardPassword
11
+ healthcheck:
12
+ test: /opt/mssql-tools/bin/sqlcmd -S mssql -U sa -P 'S0meVeryHardPassword' -Q 'select 1'
13
+ waitmssql:
14
+ image: mcr.microsoft.com/mssql/server:2017-latest
15
+ links:
16
+ - mssql
17
+ depends_on:
18
+ - mssql
19
+ entrypoint:
20
+ - bash
21
+ - -c
22
+ # https://docs.microsoft.com/en-us/sql/relational-databases/logs/control-transaction-durability?view=sql-server-ver15#bkmk_DbControl
23
+ - 'until /opt/mssql-tools/bin/sqlcmd -S mssql -U sa -P S0meVeryHardPassword -d master -Q "CREATE DATABASE knex_test; ALTER DATABASE knex_test SET DELAYED_DURABILITY = FORCED"; do sleep 5; done'
24
+
25
+ mysql:
26
+ image: mysql
27
+ # https://dev.mysql.com/doc/refman/8.0/en/mysql-acid.html
28
+ # https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_flush_method
29
+ # nosync only for unix, edit for local start on other systems
30
+ command: --default-authentication-plugin=mysql_native_password --sync_binlog=0 --innodb_doublewrite=OFF --innodb-flush-log-at-trx-commit=0 --innodb-flush-method=nosync
31
+ ports:
32
+ - '23306:3306'
33
+ environment:
34
+ - MYSQL_ROOT_PASSWORD=testrootpassword
35
+ - MYSQL_DATABASE=knex_test
36
+ - MYSQL_USER=testuser
37
+ - MYSQL_PASSWORD=testpassword
38
+ healthcheck:
39
+ test:
40
+ [
41
+ 'CMD',
42
+ '/usr/bin/mysql',
43
+ '-hlocalhost',
44
+ '-utestuser',
45
+ '-ptestpassword',
46
+ '-e',
47
+ 'SELECT 1',
48
+ ]
49
+ interval: 30s
50
+ timeout: 5s
51
+ retries: 3
52
+ restart: always
53
+ volumes:
54
+ - mysql_data:/var/lib/mysql
55
+ waitmysql:
56
+ image: mysql
57
+ links:
58
+ - mysql
59
+ depends_on:
60
+ - mysql
61
+ entrypoint:
62
+ - bash
63
+ - -c
64
+ - 'until /usr/bin/mysql -hmysql -utestuser -ptestpassword -e "SELECT 1"; do sleep 5; done'
65
+
66
+ postgres:
67
+ image: postgres:alpine
68
+ # see https://www.postgresql.org/docs/current/non-durability.html
69
+ command: '-c full_page_writes=off -c fsync=off -c synchronous_commit=off'
70
+ ports:
71
+ - '25432:5432'
72
+ environment:
73
+ - POSTGRES_USER=testuser
74
+ - POSTGRES_PASSWORD=knextest
75
+ - POSTGRES_DB=knex_test
76
+ waitpostgres:
77
+ image: postgres:alpine
78
+ links:
79
+ - postgres
80
+ depends_on:
81
+ - postgres
82
+ entrypoint:
83
+ - bash
84
+ - -c
85
+ - 'until /usr/local/bin/psql postgres://testuser:knextest@postgres/knex_test -c "SELECT 1"; do sleep 5; done'
86
+
87
+ oracledbxe:
88
+ image: quillbuilduser/oracle-18-xe
89
+ container_name: oracledbxe_container
90
+ ports:
91
+ - '21521:1521'
92
+ environment:
93
+ - ORACLE_ALLOW_REMOTE=true
94
+ waitoracledbxe:
95
+ image: quillbuilduser/oracle-18-xe
96
+ links:
97
+ - oracledbxe
98
+ depends_on:
99
+ - oracledbxe
100
+ environment:
101
+ - ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
102
+ entrypoint:
103
+ - bash
104
+ - -c
105
+ - 'until /opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s sys/Oracle18@oracledbxe/XE as sysdba <<< "SELECT 13376411 FROM DUAL; exit;" | grep "13376411"; do echo "Could not connect to oracle... sleep for a while"; sleep 5; done'
106
+
107
+ volumes:
108
+ mysql_data:
109
+ driver_opts:
110
+ type: tmpfs
111
+ device: tmpfs
@@ -1,24 +1,24 @@
1
- # Checklist for crating knex @next releases
2
-
3
- 1. Go through all commits since the last release and add them to CHANGELOG.md under unreleased changes section.
4
- 2. Commit changes to CHANGELOG
5
- 3. Check that master compiles and tests are running fine (check also that CI tests are passing)
6
-
7
- ```
8
- npm run build
9
-
10
- # run bunch of tests, but skipping coverage which doesn't really work locally at least
11
- npm plaintest
12
- npm bin_test
13
- npm oracledb:test
14
- npm mssql:init
15
- npm mssql:test
16
- npm mssql:destroy
17
- ```
18
-
19
- 4. Update package.json version to be e.g. 0.16.0-next1 or 0.16.0-next2 and commit yo master
20
- 5. Publish it under @next tag
21
-
22
- ```
23
- npm publish --tag next
24
- ```
1
+ # Checklist for crating knex @next releases
2
+
3
+ 1. Go through all commits since the last release and add them to CHANGELOG.md under unreleased changes section.
4
+ 2. Commit changes to CHANGELOG
5
+ 3. Check that master compiles and tests are running fine (check also that CI tests are passing)
6
+
7
+ ```
8
+ npm run build
9
+
10
+ # run bunch of tests, but skipping coverage which doesn't really work locally at least
11
+ npm plaintest
12
+ npm bin_test
13
+ npm oracledb:test
14
+ npm mssql:init
15
+ npm mssql:test
16
+ npm mssql:destroy
17
+ ```
18
+
19
+ 4. Update package.json version to be e.g. 0.16.0-next1 or 0.16.0-next2 and commit yo master
20
+ 5. Publish it under @next tag
21
+
22
+ ```
23
+ npm publish --tag next
24
+ ```
@@ -1,34 +1,34 @@
1
- #!/bin/bash -e
2
-
3
- changelog=node_modules/.bin/changelog
4
-
5
- update_version() {
6
- echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1
7
- echo "Updated ${1} version to ${2}"
8
- }
9
-
10
- current_version=$(node -p "require('./package').version")
11
-
12
- printf "Next version (current is $current_version)? "
13
- read next_version
14
-
15
- if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then
16
- echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1"
17
- exit 1
18
- fi
19
-
20
- next_ref="v$next_version"
21
-
22
- git add -u
23
-
24
- npm run build
25
- npm test
26
-
27
- update_version 'package.json' $next_version
28
-
29
- git commit -am "release $next_version"
30
- git tag $next_version
31
-
32
- git push --tags
33
-
34
- npm publish
1
+ #!/bin/bash -e
2
+
3
+ changelog=node_modules/.bin/changelog
4
+
5
+ update_version() {
6
+ echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1
7
+ echo "Updated ${1} version to ${2}"
8
+ }
9
+
10
+ current_version=$(node -p "require('./package').version")
11
+
12
+ printf "Next version (current is $current_version)? "
13
+ read next_version
14
+
15
+ if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then
16
+ echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1"
17
+ exit 1
18
+ fi
19
+
20
+ next_ref="v$next_version"
21
+
22
+ git add -u
23
+
24
+ npm run build
25
+ npm test
26
+
27
+ update_version 'package.json' $next_version
28
+
29
+ git commit -am "release $next_version"
30
+ git tag $next_version
31
+
32
+ git push --tags
33
+
34
+ npm publish
@@ -1,34 +1,34 @@
1
- require('sqlite3');
2
- const Knex = require('knex');
3
-
4
- const knexSqlite = Knex({
5
- client: 'sqlite',
6
- connection: ':memory:',
7
- });
8
-
9
- const knexMysql = Knex({
10
- client: 'mysql2',
11
- });
12
-
13
- const knexPg = Knex({
14
- client: 'pg',
15
- });
16
-
17
- (async function run() {
18
- await knexSqlite.schema.createTable('test', (t) => {
19
- t.increments('id').primary();
20
- t.string('data');
21
- });
22
-
23
- await knexSqlite('test').insert([{ data: 'foo' }, { data: 'bar' }]);
24
-
25
- console.log('test table data:', await knexSqlite('test'));
26
-
27
- console.log(
28
- knexPg({ f: 'foo', b: 'bar' })
29
- .select('foo.*')
30
- .where('f.name', knexPg.raw('??', ['b.name']))
31
- .whereIn('something', knexPg('bar').select('id'))
32
- .toSQL().sql
33
- );
34
- })();
1
+ require('sqlite3');
2
+ const Knex = require('knex');
3
+
4
+ const knexSqlite = Knex({
5
+ client: 'sqlite',
6
+ connection: ':memory:',
7
+ });
8
+
9
+ const knexMysql = Knex({
10
+ client: 'mysql2',
11
+ });
12
+
13
+ const knexPg = Knex({
14
+ client: 'pg',
15
+ });
16
+
17
+ (async function run() {
18
+ await knexSqlite.schema.createTable('test', (t) => {
19
+ t.increments('id').primary();
20
+ t.string('data');
21
+ });
22
+
23
+ await knexSqlite('test').insert([{ data: 'foo' }, { data: 'bar' }]);
24
+
25
+ console.log('test table data:', await knexSqlite('test'));
26
+
27
+ console.log(
28
+ knexPg({ f: 'foo', b: 'bar' })
29
+ .select('foo.*')
30
+ .where('f.name', knexPg.raw('??', ['b.name']))
31
+ .whereIn('something', knexPg('bar').select('id'))
32
+ .toSQL().sql
33
+ );
34
+ })();