knex 0.95.13 → 1.0.1
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 +74 -3
- package/README.md +1 -1
- package/UPGRADING.md +7 -0
- package/lib/client.js +14 -1
- package/lib/constants.js +2 -0
- package/lib/dialects/better-sqlite3/index.js +72 -0
- package/lib/dialects/cockroachdb/crdb-querycompiler.js +87 -33
- package/lib/dialects/cockroachdb/crdb-tablecompiler.js +19 -0
- package/lib/dialects/cockroachdb/index.js +13 -0
- package/lib/dialects/mssql/index.js +0 -11
- package/lib/dialects/mssql/query/mssql-querycompiler.js +122 -64
- package/lib/dialects/mssql/schema/mssql-columncompiler.js +41 -6
- package/lib/dialects/mssql/schema/mssql-tablecompiler.js +24 -9
- package/lib/dialects/mssql/schema/mssql-viewcompiler.js +15 -1
- package/lib/dialects/mysql/index.js +3 -7
- package/lib/dialects/mysql/query/mysql-querycompiler.js +91 -5
- package/lib/dialects/mysql/schema/mysql-columncompiler.js +32 -5
- package/lib/dialects/mysql/schema/mysql-tablecompiler.js +28 -4
- package/lib/dialects/mysql2/index.js +7 -4
- package/lib/dialects/oracle/query/oracle-querycompiler.js +7 -6
- package/lib/dialects/oracle/schema/internal/trigger.js +1 -1
- package/lib/dialects/oracle/schema/oracle-columncompiler.js +10 -4
- package/lib/dialects/oracle/schema/oracle-tablecompiler.js +17 -6
- package/lib/dialects/oracledb/index.js +0 -4
- package/lib/dialects/oracledb/query/oracledb-querycompiler.js +104 -0
- package/lib/dialects/oracledb/schema/oracledb-columncompiler.js +23 -0
- package/lib/dialects/postgres/index.js +21 -6
- package/lib/dialects/postgres/query/pg-querybuilder.js +8 -0
- package/lib/dialects/postgres/query/pg-querycompiler.js +166 -5
- package/lib/dialects/postgres/schema/pg-columncompiler.js +24 -4
- package/lib/dialects/postgres/schema/pg-tablecompiler.js +55 -47
- package/lib/dialects/redshift/index.js +12 -0
- package/lib/dialects/redshift/query/redshift-querycompiler.js +62 -26
- package/lib/dialects/redshift/schema/redshift-columncompiler.js +2 -1
- package/lib/dialects/redshift/schema/redshift-tablecompiler.js +4 -1
- package/lib/dialects/sqlite3/index.js +18 -4
- package/lib/dialects/sqlite3/query/sqlite-querycompiler.js +85 -18
- package/lib/dialects/sqlite3/schema/ddl.js +274 -282
- package/lib/dialects/sqlite3/schema/internal/sqlite-ddl-operations.js +18 -8
- package/lib/dialects/sqlite3/schema/sqlite-columncompiler.js +20 -0
- package/lib/dialects/sqlite3/schema/sqlite-compiler.js +16 -12
- package/lib/dialects/sqlite3/schema/sqlite-tablecompiler.js +15 -5
- package/lib/dialects/sqlite3/schema/sqlite-viewcompiler.js +31 -2
- package/lib/execution/runner.js +37 -2
- package/lib/knex-builder/FunctionHelper.js +21 -0
- package/lib/migrations/common/MigrationsLoader.js +36 -0
- package/lib/migrations/migrate/MigrationGenerator.js +1 -1
- package/lib/migrations/migrate/Migrator.js +20 -23
- package/lib/migrations/migrate/migration-list-resolver.js +2 -5
- package/lib/migrations/migrate/{configuration-merger.js → migrator-configuration-merger.js} +2 -4
- package/lib/migrations/migrate/sources/fs-migrations.js +4 -29
- package/lib/migrations/migrate/stub/js.stub +8 -1
- package/lib/migrations/migrate/stub/knexfile-js.stub +3 -0
- package/lib/migrations/migrate/stub/knexfile-ts.stub +5 -2
- package/lib/migrations/migrate/table-creator.js +6 -5
- package/lib/migrations/seed/Seeder.js +25 -92
- package/lib/migrations/seed/seeder-configuration-merger.js +60 -0
- package/lib/migrations/seed/sources/fs-seeds.js +65 -0
- package/lib/migrations/seed/stub/js.stub +4 -1
- package/lib/migrations/util/import-file.js +0 -1
- package/lib/query/joinclause.js +24 -5
- package/lib/query/method-constants.js +37 -0
- package/lib/query/querybuilder.js +230 -5
- package/lib/query/querycompiler.js +269 -84
- package/lib/schema/columnbuilder.js +8 -0
- package/lib/schema/columncompiler.js +132 -5
- package/lib/schema/compiler.js +1 -0
- package/lib/schema/tablebuilder.js +41 -8
- package/lib/schema/tablecompiler.js +57 -0
- package/lib/schema/viewcompiler.js +13 -10
- package/package.json +35 -22
- package/scripts/docker-compose.yml +7 -7
- package/scripts/oracledb-install-driver-libs.sh +82 -0
- package/scripts/runkit-example.js +1 -1
- package/scripts/stress-test/docker-compose.yml +3 -3
- package/scripts/stress-test/knex-stress-test.js +1 -1
- package/scripts/stress-test/reconnect-test-mysql-based-drivers.js +1 -1
- package/types/index.d.ts +124 -20
|
@@ -10,7 +10,7 @@ const each = require('lodash/each');
|
|
|
10
10
|
const extend = require('lodash/extend');
|
|
11
11
|
const toArray = require('lodash/toArray');
|
|
12
12
|
const helpers = require('../util/helpers');
|
|
13
|
-
const { isString, isFunction } = require('../util/is');
|
|
13
|
+
const { isString, isFunction, isObject } = require('../util/is');
|
|
14
14
|
|
|
15
15
|
class TableBuilder {
|
|
16
16
|
constructor(client, method, tableName, tableNameLike, fn) {
|
|
@@ -50,16 +50,20 @@ class TableBuilder {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// The "timestamps" call is really just sets the `created_at` and `updated_at` columns.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
|
|
54
|
+
timestamps(useTimestamps, defaultToNow, useCamelCase) {
|
|
55
|
+
if (isObject(useTimestamps)) {
|
|
56
|
+
({ useTimestamps, defaultToNow, useCamelCase } = useTimestamps);
|
|
57
|
+
}
|
|
58
|
+
const method = useTimestamps === true ? 'timestamp' : 'datetime';
|
|
59
|
+
const createdAt = this[method](useCamelCase ? 'createdAt' : 'created_at');
|
|
60
|
+
const updatedAt = this[method](useCamelCase ? 'updatedAt' : 'updated_at');
|
|
61
|
+
|
|
62
|
+
if (defaultToNow === true) {
|
|
58
63
|
const now = this.client.raw('CURRENT_TIMESTAMP');
|
|
59
64
|
createdAt.notNullable().defaultTo(now);
|
|
60
65
|
updatedAt.notNullable().defaultTo(now);
|
|
61
66
|
}
|
|
62
|
-
return;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
// Set the comment value for a table, they're only allowed to be called
|
|
@@ -142,6 +146,14 @@ class TableBuilder {
|
|
|
142
146
|
};
|
|
143
147
|
return returnObj;
|
|
144
148
|
}
|
|
149
|
+
|
|
150
|
+
check(checkPredicate, bindings, constraintName) {
|
|
151
|
+
this._statements.push({
|
|
152
|
+
grouping: 'checks',
|
|
153
|
+
args: [checkPredicate, bindings, constraintName],
|
|
154
|
+
});
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
145
157
|
}
|
|
146
158
|
|
|
147
159
|
[
|
|
@@ -290,7 +302,12 @@ const AlterMethods = {
|
|
|
290
302
|
},
|
|
291
303
|
|
|
292
304
|
dropTimestamps() {
|
|
293
|
-
|
|
305
|
+
// arguments[0] = useCamelCase
|
|
306
|
+
return this.dropColumns(
|
|
307
|
+
arguments[0] === true
|
|
308
|
+
? ['createdAt', 'updatedAt']
|
|
309
|
+
: ['created_at', 'updated_at']
|
|
310
|
+
);
|
|
294
311
|
},
|
|
295
312
|
|
|
296
313
|
setNullable(column) {
|
|
@@ -303,6 +320,22 @@ const AlterMethods = {
|
|
|
303
320
|
return this;
|
|
304
321
|
},
|
|
305
322
|
|
|
323
|
+
check(checkPredicate, bindings, constraintName) {
|
|
324
|
+
this._statements.push({
|
|
325
|
+
grouping: 'alterTable',
|
|
326
|
+
method: 'check',
|
|
327
|
+
args: [checkPredicate, bindings, constraintName],
|
|
328
|
+
});
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
dropChecks() {
|
|
332
|
+
this._statements.push({
|
|
333
|
+
grouping: 'alterTable',
|
|
334
|
+
method: 'dropChecks',
|
|
335
|
+
args: toArray(arguments),
|
|
336
|
+
});
|
|
337
|
+
},
|
|
338
|
+
|
|
306
339
|
dropNullable(column) {
|
|
307
340
|
this._statements.push({
|
|
308
341
|
grouping: 'alterTable',
|
|
@@ -12,6 +12,7 @@ const groupBy = require('lodash/groupBy');
|
|
|
12
12
|
const indexOf = require('lodash/indexOf');
|
|
13
13
|
const isEmpty = require('lodash/isEmpty');
|
|
14
14
|
const tail = require('lodash/tail');
|
|
15
|
+
const { normalizeArr } = require('../util/helpers');
|
|
15
16
|
|
|
16
17
|
class TableCompiler {
|
|
17
18
|
constructor(client, tableBuilder) {
|
|
@@ -32,6 +33,8 @@ class TableCompiler {
|
|
|
32
33
|
|
|
33
34
|
this.sequence = [];
|
|
34
35
|
this._formatting = client.config && client.config.formatting;
|
|
36
|
+
|
|
37
|
+
this.checksCount = 0;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
// Convert the tableCompiler toSQL
|
|
@@ -346,6 +349,43 @@ class TableCompiler {
|
|
|
346
349
|
return this._setNullableState(column, false);
|
|
347
350
|
}
|
|
348
351
|
|
|
352
|
+
dropChecks(checkConstraintNames) {
|
|
353
|
+
if (checkConstraintNames === undefined) return '';
|
|
354
|
+
checkConstraintNames = normalizeArr(checkConstraintNames);
|
|
355
|
+
const tableName = this.tableName();
|
|
356
|
+
const sql = `alter table ${tableName} ${checkConstraintNames
|
|
357
|
+
.map((constraint) => `drop constraint ${constraint}`)
|
|
358
|
+
.join(', ')}`;
|
|
359
|
+
this.pushQuery(sql);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
check(checkPredicate, bindings, constraintName) {
|
|
363
|
+
const tableName = this.tableName();
|
|
364
|
+
let checkConstraint = constraintName;
|
|
365
|
+
if (!checkConstraint) {
|
|
366
|
+
this.checksCount++;
|
|
367
|
+
checkConstraint = tableName + '_' + this.checksCount;
|
|
368
|
+
}
|
|
369
|
+
const sql = `alter table ${tableName} add constraint ${checkConstraint} check(${checkPredicate})`;
|
|
370
|
+
this.pushQuery(sql);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
_addChecks() {
|
|
374
|
+
if (this.grouped.checks) {
|
|
375
|
+
return (
|
|
376
|
+
', ' +
|
|
377
|
+
this.grouped.checks
|
|
378
|
+
.map((c) => {
|
|
379
|
+
return `${
|
|
380
|
+
c.args[2] ? 'constraint ' + c.args[2] + ' ' : ''
|
|
381
|
+
}check (${this.client.raw(c.args[0], c.args[1])})`;
|
|
382
|
+
})
|
|
383
|
+
.join(', ')
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
return '';
|
|
387
|
+
}
|
|
388
|
+
|
|
349
389
|
// If no name was specified for this index, we will create one using a basic
|
|
350
390
|
// convention of the table name, followed by the columns, followed by an
|
|
351
391
|
// index type, such as primary or index, which makes the index unique.
|
|
@@ -361,6 +401,23 @@ class TableCompiler {
|
|
|
361
401
|
).toLowerCase();
|
|
362
402
|
return this.formatter.wrap(indexName);
|
|
363
403
|
}
|
|
404
|
+
|
|
405
|
+
_getPrimaryKeys() {
|
|
406
|
+
return (this.grouped.alterTable || [])
|
|
407
|
+
.filter((a) => a.method === 'primary')
|
|
408
|
+
.flatMap((a) => a.args)
|
|
409
|
+
.flat();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
_canBeAddPrimaryKey(options) {
|
|
413
|
+
return options.primaryKey && this._getPrimaryKeys().length === 0;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
_getIncrementsColumnNames() {
|
|
417
|
+
return this.grouped.columns
|
|
418
|
+
.filter((c) => c.builder._type === 'increments')
|
|
419
|
+
.map((c) => c.builder._args[0]);
|
|
420
|
+
}
|
|
364
421
|
}
|
|
365
422
|
|
|
366
423
|
TableCompiler.prototype.pushQuery = pushQuery;
|
|
@@ -52,16 +52,19 @@ class ViewCompiler {
|
|
|
52
52
|
const createStatement =
|
|
53
53
|
'create ' +
|
|
54
54
|
(materialized ? 'materialized ' : '') +
|
|
55
|
-
'
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
(replace ? 'or replace ' : '') +
|
|
56
|
+
'view ';
|
|
57
|
+
const columnList = columns
|
|
58
|
+
? ' (' +
|
|
59
|
+
columnize_(
|
|
60
|
+
columns,
|
|
61
|
+
this.viewBuilder,
|
|
62
|
+
this.client,
|
|
63
|
+
this.bindingsHolder
|
|
64
|
+
) +
|
|
65
|
+
')'
|
|
66
|
+
: '';
|
|
67
|
+
let sql = createStatement + this.viewName() + columnList;
|
|
65
68
|
sql += ' as ';
|
|
66
69
|
sql += selectQuery.toString();
|
|
67
70
|
switch (this.single.checkOption) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3",
|
|
5
5
|
"main": "knex",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=12"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"format": "prettier --write \"{lib,bin,scripts,test}/**/*.js\"",
|
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
"test:mysql2": "cross-env DB=mysql2 npm run test:db",
|
|
29
29
|
"test:oracledb": "cross-env DB=oracledb npm run test:db",
|
|
30
30
|
"test:sqlite": "cross-env DB=sqlite3 npm run test:db",
|
|
31
|
+
"test:better-sqlite3": "cross-env DB=better-sqlite3 npm run test:db",
|
|
31
32
|
"test:postgres": "cross-env DB=postgres npm run test:db",
|
|
32
33
|
"test:cockroachdb": "cross-env DB=cockroachdb npm run test:db",
|
|
33
34
|
"test:pgnative": "cross-env DB=pgnative npm run test:db",
|
|
34
35
|
"test:tape": "node test/tape/index.js | tap-spec",
|
|
35
36
|
"test:cli": "cross-env KNEX_PATH=../knex.js KNEX=bin/cli.js jake -f test/jake/Jakefile",
|
|
36
|
-
"db:start": "docker-compose -f scripts/docker-compose.yml up --build -d mysql
|
|
37
|
+
"db:start": "docker-compose -f scripts/docker-compose.yml up --build -d mysql oracledb postgres mssql cockroachdb pgnative && docker-compose -f scripts/docker-compose.yml up waitmssql waitmysql waitpostgres waitoracledb",
|
|
37
38
|
"db:start:no-oracle": "docker-compose -f scripts/docker-compose.yml up --build -d mysql postgres mssql cockroachdb pgnative && docker-compose -f scripts/docker-compose.yml up waitmssql waitmysql waitpostgres",
|
|
38
39
|
"db:stop": "docker-compose -f scripts/docker-compose.yml down",
|
|
39
40
|
"db:start:postgres": "docker-compose -f scripts/docker-compose.yml up --build -d postgres && docker-compose -f scripts/docker-compose.yml up waitpostgres",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"db:stop:mssql": "docker-compose -f scripts/docker-compose.yml down",
|
|
47
48
|
"db:start:cockroachdb": "docker-compose -f scripts/docker-compose.yml up --build -d cockroachdb && docker-compose -f scripts/docker-compose.yml up waitcockroachdb",
|
|
48
49
|
"db:stop:cockroachdb": "docker-compose -f scripts/docker-compose.yml down",
|
|
49
|
-
"db:start:oracle": "docker-compose -f scripts/docker-compose.yml up --build -d
|
|
50
|
+
"db:start:oracle": "docker-compose -f scripts/docker-compose.yml up --build -d oracledb && docker-compose -f scripts/docker-compose.yml up waitoracledb",
|
|
50
51
|
"db:stop:oracle": "docker-compose -f scripts/docker-compose.yml down",
|
|
51
52
|
"stress:init": "docker-compose -f scripts/stress-test/docker-compose.yml up --no-start && docker-compose -f scripts/stress-test/docker-compose.yml start",
|
|
52
53
|
"stress:test": "node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '",
|
|
@@ -54,17 +55,17 @@
|
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
57
|
"colorette": "2.0.16",
|
|
57
|
-
"commander": "^
|
|
58
|
-
"debug": "4.3.
|
|
58
|
+
"commander": "^8.3.0",
|
|
59
|
+
"debug": "4.3.3",
|
|
59
60
|
"escalade": "^3.1.1",
|
|
60
61
|
"esm": "^3.2.25",
|
|
61
|
-
"getopts": "2.
|
|
62
|
+
"getopts": "2.3.0",
|
|
62
63
|
"interpret": "^2.2.0",
|
|
63
64
|
"lodash": "^4.17.21",
|
|
64
65
|
"pg-connection-string": "2.5.0",
|
|
65
|
-
"rechoir": "0.
|
|
66
|
+
"rechoir": "^0.8.0",
|
|
66
67
|
"resolve-from": "^5.0.0",
|
|
67
|
-
"tarn": "^3.0.
|
|
68
|
+
"tarn": "^3.0.2",
|
|
68
69
|
"tildify": "2.0.0"
|
|
69
70
|
},
|
|
70
71
|
"peerDependenciesMeta": {
|
|
@@ -85,6 +86,12 @@
|
|
|
85
86
|
},
|
|
86
87
|
"sqlite3": {
|
|
87
88
|
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"@vscode/sqlite3": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"better-sqlite3": {
|
|
94
|
+
"optional": true
|
|
88
95
|
}
|
|
89
96
|
},
|
|
90
97
|
"lint-staged": {
|
|
@@ -94,14 +101,16 @@
|
|
|
94
101
|
]
|
|
95
102
|
},
|
|
96
103
|
"devDependencies": {
|
|
97
|
-
"@types/node": "^16.
|
|
104
|
+
"@types/node": "^16.11.19",
|
|
105
|
+
"@vscode/sqlite3": "^5.0.7",
|
|
106
|
+
"better-sqlite3": "^7.4.6",
|
|
98
107
|
"chai": "^4.3.4",
|
|
99
108
|
"chai-as-promised": "^7.1.1",
|
|
100
109
|
"chai-subset-in-order": "^3.1.0",
|
|
101
110
|
"cli-testlab": "^2.2.0",
|
|
102
111
|
"coveralls": "^3.1.1",
|
|
103
112
|
"cross-env": "^7.0.3",
|
|
104
|
-
"dtslint": "4.2.
|
|
113
|
+
"dtslint": "4.2.1",
|
|
105
114
|
"eslint": "^8.1.0",
|
|
106
115
|
"eslint-config-prettier": "^8.3.0",
|
|
107
116
|
"eslint-plugin-import": "^2.25.2",
|
|
@@ -109,27 +118,26 @@
|
|
|
109
118
|
"jake": "^8.1.1",
|
|
110
119
|
"JSONStream": "^1.3.5",
|
|
111
120
|
"lint-staged": "^11.1.2",
|
|
112
|
-
"mocha": "^9.1.
|
|
113
|
-
"mock-fs": "^
|
|
121
|
+
"mocha": "^9.1.4",
|
|
122
|
+
"mock-fs": "^5.1.2",
|
|
114
123
|
"mysql": "^2.18.1",
|
|
115
|
-
"mysql2": "^2.3.
|
|
124
|
+
"mysql2": "^2.3.3",
|
|
116
125
|
"nyc": "^15.1.0",
|
|
117
|
-
"oracledb": "^5.
|
|
126
|
+
"oracledb": "^5.3.0",
|
|
118
127
|
"pg": "^8.7.1",
|
|
119
128
|
"pg-query-stream": "^4.2.1",
|
|
120
129
|
"prettier": "2.4.1",
|
|
121
130
|
"rimraf": "^3.0.2",
|
|
122
|
-
"sinon": "^
|
|
131
|
+
"sinon": "^12.0.1",
|
|
123
132
|
"sinon-chai": "^3.7.0",
|
|
124
|
-
"source-map-support": "^0.5.
|
|
125
|
-
"sqlite3": "^5.0.2",
|
|
133
|
+
"source-map-support": "^0.5.21",
|
|
126
134
|
"tap-spec": "^5.0.0",
|
|
127
|
-
"tape": "^5.
|
|
135
|
+
"tape": "^5.4.0",
|
|
128
136
|
"tedious": "^12.2.0",
|
|
129
137
|
"toxiproxy-node-client": "^2.0.6",
|
|
130
|
-
"ts-node": "^10.
|
|
131
|
-
"tsd": "^0.
|
|
132
|
-
"typescript": "4.
|
|
138
|
+
"ts-node": "^10.4.0",
|
|
139
|
+
"tsd": "^0.19.1",
|
|
140
|
+
"typescript": "4.5.4"
|
|
133
141
|
},
|
|
134
142
|
"buildDependencies": [
|
|
135
143
|
"rimraf"
|
|
@@ -180,6 +188,9 @@
|
|
|
180
188
|
{
|
|
181
189
|
"name": "Brian Lauber",
|
|
182
190
|
"web": "https://briandamaged.org"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "Olivier Cavadenti"
|
|
183
194
|
}
|
|
184
195
|
],
|
|
185
196
|
"browser": {
|
|
@@ -194,6 +205,8 @@
|
|
|
194
205
|
"pg-query-stream": false,
|
|
195
206
|
"oracle": false,
|
|
196
207
|
"sqlite3": false,
|
|
208
|
+
"@vscode/sqlite3": false,
|
|
209
|
+
"better-sqlite3": false,
|
|
197
210
|
"oracledb": false
|
|
198
211
|
},
|
|
199
212
|
"react-native": {
|
|
@@ -85,7 +85,7 @@ services:
|
|
|
85
85
|
- 'until /usr/local/bin/psql postgres://testuser:knextest@postgres/knex_test -c "SELECT 1"; do sleep 5; done'
|
|
86
86
|
|
|
87
87
|
cockroachdb:
|
|
88
|
-
image: cockroachdb/cockroach:latest-v21.
|
|
88
|
+
image: cockroachdb/cockroach:latest-v21.2
|
|
89
89
|
container_name: crdb
|
|
90
90
|
hostname: crdb
|
|
91
91
|
command: start-single-node --cluster-name=example-single-node --insecure
|
|
@@ -125,25 +125,25 @@ services:
|
|
|
125
125
|
- -c
|
|
126
126
|
- 'until /usr/local/bin/psql postgres://testuser:knextest@pgnative/knex_test -c "SELECT 1"; do sleep 5; done'
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
oracledb:
|
|
129
129
|
image: quillbuilduser/oracle-18-xe
|
|
130
|
-
container_name:
|
|
130
|
+
container_name: oracledb_container
|
|
131
131
|
ports:
|
|
132
132
|
- '21521:1521'
|
|
133
133
|
environment:
|
|
134
134
|
- ORACLE_ALLOW_REMOTE=true
|
|
135
|
-
|
|
135
|
+
waitoracledb:
|
|
136
136
|
image: quillbuilduser/oracle-18-xe
|
|
137
137
|
links:
|
|
138
|
-
-
|
|
138
|
+
- oracledb
|
|
139
139
|
depends_on:
|
|
140
|
-
-
|
|
140
|
+
- oracledb
|
|
141
141
|
environment:
|
|
142
142
|
- ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
|
|
143
143
|
entrypoint:
|
|
144
144
|
- bash
|
|
145
145
|
- -c
|
|
146
|
-
- 'until /opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s sys/Oracle18@
|
|
146
|
+
- 'until /opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s sys/Oracle18@oracledb/XE as sysdba <<< "SELECT 13376411 FROM DUAL; exit;" | grep "13376411"; do echo "Could not connect to oracle... sleep for a while"; sleep 5; done'
|
|
147
147
|
|
|
148
148
|
volumes:
|
|
149
149
|
mysql_data:
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Exit on error
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
# Directory constants
|
|
7
|
+
repo_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )"
|
|
8
|
+
exec_dir="$( pwd )"
|
|
9
|
+
script_dir="$repo_dir/scripts/"
|
|
10
|
+
docker_compose_file="$repo_dir/scripts/docker-compose.yml"
|
|
11
|
+
|
|
12
|
+
help_text="
|
|
13
|
+
Helper script to install oracle drivers on local linux machine from Oracle
|
|
14
|
+
database container.
|
|
15
|
+
|
|
16
|
+
oracledb-install-driver-libs.sh COMMAND
|
|
17
|
+
|
|
18
|
+
COMMAND:
|
|
19
|
+
run: Do the driver install.
|
|
20
|
+
dry-run: Do the driver install but do not save any files.
|
|
21
|
+
help: Print this menu.
|
|
22
|
+
|
|
23
|
+
NOTES FOR USAGE:
|
|
24
|
+
1. This script is tested to work on Ubuntu 18.04 LTS.
|
|
25
|
+
2. This script requires you to have sudo capabilities so to use ldconfig.
|
|
26
|
+
"
|
|
27
|
+
|
|
28
|
+
# Main script logic
|
|
29
|
+
cmd="$1"
|
|
30
|
+
|
|
31
|
+
function main () {
|
|
32
|
+
case "$1" in
|
|
33
|
+
"run")
|
|
34
|
+
printf "Starting run ...\n"
|
|
35
|
+
do_install true
|
|
36
|
+
exit 0
|
|
37
|
+
;;
|
|
38
|
+
"dry-run")
|
|
39
|
+
printf "Starting dry-run ...\n"
|
|
40
|
+
do_install false
|
|
41
|
+
exit 0
|
|
42
|
+
;;
|
|
43
|
+
"help"|"--help"|"-h"|"")
|
|
44
|
+
printf "$help_text"
|
|
45
|
+
exit 0
|
|
46
|
+
;;
|
|
47
|
+
*)
|
|
48
|
+
printf "Unsupported command: $cmd\n"
|
|
49
|
+
printf "Try running with 'help' to see supported commands.\n"
|
|
50
|
+
exit 1
|
|
51
|
+
;;
|
|
52
|
+
esac
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function do_install () {
|
|
56
|
+
do_changes="$1"
|
|
57
|
+
printf "\nEnsuring oracle containers from docker-compose are up ...\n"
|
|
58
|
+
docker-compose -f "$docker_compose_file" up --build -d oracledb
|
|
59
|
+
docker-compose -f "$docker_compose_file" up waitoracledb
|
|
60
|
+
printf "\nSleeping an extra 15 seconds to ensure oracle has fully started ...\n"
|
|
61
|
+
sleep 15
|
|
62
|
+
printf "\nInstalling oracle client libs to db container ...\n"
|
|
63
|
+
set -x
|
|
64
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb curl http://yum.oracle.com/public-yum-ol7.repo -o /etc/yum.repos.d/public-yum-ol7.repo
|
|
65
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb yum install -y yum-utils
|
|
66
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb yum-config-manager --enable ol7_oracle_instantclient
|
|
67
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb yum install -y oracle-instantclient18.3-basiclite
|
|
68
|
+
set +x
|
|
69
|
+
printf "\nCopying to host's ~/lib directory and adding to ldconfig ...\n"
|
|
70
|
+
if [ "$do_changes" = "true" ]; then
|
|
71
|
+
set -x
|
|
72
|
+
docker cp oracledb_container:/usr/lib/oracle/18.3/client64/lib/ ~/
|
|
73
|
+
sudo sh -c "echo $HOME/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
|
|
74
|
+
sudo ldconfig
|
|
75
|
+
set +x
|
|
76
|
+
else
|
|
77
|
+
printf "(skipping because dry-run)\n"
|
|
78
|
+
fi
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Start the bash app's main function
|
|
82
|
+
main "$cmd"
|
|
@@ -14,7 +14,7 @@ services:
|
|
|
14
14
|
- "mysql"
|
|
15
15
|
- "postgresql"
|
|
16
16
|
- "pgnative"
|
|
17
|
-
- "
|
|
17
|
+
- "oracledb"
|
|
18
18
|
- "mssql"
|
|
19
19
|
|
|
20
20
|
mysql:
|
|
@@ -41,8 +41,8 @@ services:
|
|
|
41
41
|
- POSTGRES_PASSWORD=postgresrootpassword
|
|
42
42
|
- POSTGRES_USER=postgres
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
image:
|
|
44
|
+
oracledb:
|
|
45
|
+
image: quillbuilduser/oracle-18-xe
|
|
46
46
|
ports:
|
|
47
47
|
- "31521:1521"
|
|
48
48
|
environment:
|
|
@@ -163,7 +163,7 @@ async function main() {
|
|
|
163
163
|
await recreateProxy('postgresql', 25432, 5432);
|
|
164
164
|
await recreateProxy('postgresql', 25433, 5433);
|
|
165
165
|
await recreateProxy('mysql', 23306, 3306);
|
|
166
|
-
await recreateProxy('
|
|
166
|
+
await recreateProxy('oracledb', 21521, 1521);
|
|
167
167
|
await recreateProxy('mssql', 21433, 1433);
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -147,7 +147,7 @@ async function main() {
|
|
|
147
147
|
console.log('----- Recreating proxies -> cutting connections completely');
|
|
148
148
|
await recreateProxy('postgresql', 25432, 5432);
|
|
149
149
|
await recreateProxy('mysql', 23306, 3306);
|
|
150
|
-
await recreateProxy('
|
|
150
|
+
await recreateProxy('oracledb', 21521, 1521);
|
|
151
151
|
}
|
|
152
152
|
setInterval(() => recreateProxies(), 2000);
|
|
153
153
|
|