knex 2.5.1 → 3.0.0
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 +14 -1
- package/LICENSE +22 -22
- package/lib/dialects/oracledb/index.js +1 -1
- package/lib/migrations/migrate/Migrator.js +1 -0
- package/lib/migrations/migrate/stub/cjs.stub +15 -15
- package/lib/migrations/migrate/stub/coffee.stub +13 -13
- package/lib/migrations/migrate/stub/eg.stub +14 -14
- package/lib/migrations/migrate/stub/js-schema.stub +22 -22
- package/lib/migrations/migrate/stub/js.stub +22 -22
- package/lib/migrations/migrate/stub/knexfile-coffee.stub +34 -34
- package/lib/migrations/migrate/stub/knexfile-eg.stub +43 -43
- package/lib/migrations/migrate/stub/knexfile-js.stub +47 -47
- package/lib/migrations/migrate/stub/knexfile-ls.stub +35 -35
- package/lib/migrations/migrate/stub/knexfile-ts.stub +47 -47
- package/lib/migrations/migrate/stub/ls.stub +14 -14
- package/lib/migrations/migrate/stub/mjs.stub +23 -23
- package/lib/migrations/migrate/stub/ts-schema.stub +21 -21
- package/lib/migrations/migrate/stub/ts.stub +21 -21
- package/lib/migrations/seed/stub/coffee.stub +9 -9
- package/lib/migrations/seed/stub/eg.stub +11 -11
- package/lib/migrations/seed/stub/js.stub +13 -13
- package/lib/migrations/seed/stub/ls.stub +11 -11
- package/lib/migrations/seed/stub/mjs.stub +12 -12
- package/lib/migrations/seed/stub/ts.stub +13 -13
- package/package.json +5 -5
- package/scripts/oracledb-install-driver-libs.sh +82 -82
- package/scripts/release.sh +36 -36
- package/scripts/stress-test/README.txt +18 -18
- package/types/index.d.ts +13 -15
- package/lib/dialects/index.js +0 -34
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import type { Knex } from "knex";
|
|
2
|
-
|
|
3
|
-
// Update with your config settings.
|
|
4
|
-
|
|
5
|
-
const config: { [key: string]: Knex.Config } = {
|
|
6
|
-
development: {
|
|
7
|
-
client: "sqlite3",
|
|
8
|
-
connection: {
|
|
9
|
-
filename: "./dev.sqlite3"
|
|
10
|
-
}
|
|
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
|
-
|
|
29
|
-
production: {
|
|
30
|
-
client: "postgresql",
|
|
31
|
-
connection: {
|
|
32
|
-
database: "my_db",
|
|
33
|
-
user: "username",
|
|
34
|
-
password: "password"
|
|
35
|
-
},
|
|
36
|
-
pool: {
|
|
37
|
-
min: 2,
|
|
38
|
-
max: 10
|
|
39
|
-
},
|
|
40
|
-
migrations: {
|
|
41
|
-
tableName: "knex_migrations"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
module.exports = config;
|
|
1
|
+
import type { Knex } from "knex";
|
|
2
|
+
|
|
3
|
+
// Update with your config settings.
|
|
4
|
+
|
|
5
|
+
const config: { [key: string]: Knex.Config } = {
|
|
6
|
+
development: {
|
|
7
|
+
client: "sqlite3",
|
|
8
|
+
connection: {
|
|
9
|
+
filename: "./dev.sqlite3"
|
|
10
|
+
}
|
|
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
|
+
|
|
29
|
+
production: {
|
|
30
|
+
client: "postgresql",
|
|
31
|
+
connection: {
|
|
32
|
+
database: "my_db",
|
|
33
|
+
user: "username",
|
|
34
|
+
password: "password"
|
|
35
|
+
},
|
|
36
|
+
pool: {
|
|
37
|
+
min: 2,
|
|
38
|
+
max: 10
|
|
39
|
+
},
|
|
40
|
+
migrations: {
|
|
41
|
+
tableName: "knex_migrations"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = config;
|
|
@@ -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
|
+
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @param { import("knex").Knex } knex
|
|
4
|
-
* @returns { Promise<void> }
|
|
5
|
-
*/
|
|
6
|
-
export const up = async (knex) => {
|
|
7
|
-
<% if (d.tableName) { %>
|
|
8
|
-
await knex.schema.createTable("<%= d.tableName %>", function(t) {
|
|
9
|
-
t.increments();
|
|
10
|
-
t.timestamp();
|
|
11
|
-
});
|
|
12
|
-
<% } %>
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param { import("knex").Knex } knex
|
|
17
|
-
* @returns { Promise<void> }
|
|
18
|
-
*/
|
|
19
|
-
export const down = async (knex) => {
|
|
20
|
-
<% if (d.tableName) { %>
|
|
21
|
-
await knex.schema.dropTable("<%= d.tableName %>");
|
|
22
|
-
<% } %>
|
|
23
|
-
};
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @param { import("knex").Knex } knex
|
|
4
|
+
* @returns { Promise<void> }
|
|
5
|
+
*/
|
|
6
|
+
export const up = async (knex) => {
|
|
7
|
+
<% if (d.tableName) { %>
|
|
8
|
+
await knex.schema.createTable("<%= d.tableName %>", function(t) {
|
|
9
|
+
t.increments();
|
|
10
|
+
t.timestamp();
|
|
11
|
+
});
|
|
12
|
+
<% } %>
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param { import("knex").Knex } knex
|
|
17
|
+
* @returns { Promise<void> }
|
|
18
|
+
*/
|
|
19
|
+
export const down = async (knex) => {
|
|
20
|
+
<% if (d.tableName) { %>
|
|
21
|
+
await knex.schema.dropTable("<%= d.tableName %>");
|
|
22
|
+
<% } %>
|
|
23
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Knex } from "knex";
|
|
2
|
-
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
export async function up({schema}: Knex): Promise<Knex.SchemaBuilder> {
|
|
5
|
-
return schema.createTable("<%= d.tableName %>", (t) => {
|
|
6
|
-
t.increments();
|
|
7
|
-
t.timestamps();
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
<% } else { %>
|
|
11
|
-
export async function up({schema}: Knex): Promise<void> {
|
|
12
|
-
}
|
|
13
|
-
<% } %>
|
|
14
|
-
<% if (d.tableName) { %>
|
|
15
|
-
export async function down({schema}: Knex): Promise<Knex.SchemaBuilder> {
|
|
16
|
-
return schema.dropTable("<%= d.tableName %>");
|
|
17
|
-
}
|
|
18
|
-
<% } else { %>
|
|
19
|
-
export async function down({schema}: Knex): Promise<void> {
|
|
20
|
-
}
|
|
21
|
-
<% } %>
|
|
1
|
+
import { Knex } from "knex";
|
|
2
|
+
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
export async function up({schema}: Knex): Promise<Knex.SchemaBuilder> {
|
|
5
|
+
return schema.createTable("<%= d.tableName %>", (t) => {
|
|
6
|
+
t.increments();
|
|
7
|
+
t.timestamps();
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
<% } else { %>
|
|
11
|
+
export async function up({schema}: Knex): Promise<void> {
|
|
12
|
+
}
|
|
13
|
+
<% } %>
|
|
14
|
+
<% if (d.tableName) { %>
|
|
15
|
+
export async function down({schema}: Knex): Promise<Knex.SchemaBuilder> {
|
|
16
|
+
return schema.dropTable("<%= d.tableName %>");
|
|
17
|
+
}
|
|
18
|
+
<% } else { %>
|
|
19
|
+
export async function down({schema}: Knex): Promise<void> {
|
|
20
|
+
}
|
|
21
|
+
<% } %>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Knex } from "knex";
|
|
2
|
-
|
|
3
|
-
<% if (d.tableName) { %>
|
|
4
|
-
export async function up(knex: Knex): Promise<Knex.SchemaBuilder> {
|
|
5
|
-
return knex.schema.createTable("<%= d.tableName %>", (t) => {
|
|
6
|
-
t.increments();
|
|
7
|
-
t.timestamps();
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
<% } else { %>
|
|
11
|
-
export async function up(knex: Knex): Promise<void> {
|
|
12
|
-
}
|
|
13
|
-
<% } %>
|
|
14
|
-
<% if (d.tableName) { %>
|
|
15
|
-
export async function down(knex: Knex): Promise<Knex.SchemaBuilder> {
|
|
16
|
-
return knex.schema.dropTable("<%= d.tableName %>");
|
|
17
|
-
}
|
|
18
|
-
<% } else { %>
|
|
19
|
-
export async function down(knex: Knex): Promise<void> {
|
|
20
|
-
}
|
|
21
|
-
<% } %>
|
|
1
|
+
import { Knex } from "knex";
|
|
2
|
+
|
|
3
|
+
<% if (d.tableName) { %>
|
|
4
|
+
export async function up(knex: Knex): Promise<Knex.SchemaBuilder> {
|
|
5
|
+
return knex.schema.createTable("<%= d.tableName %>", (t) => {
|
|
6
|
+
t.increments();
|
|
7
|
+
t.timestamps();
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
<% } else { %>
|
|
11
|
+
export async function up(knex: Knex): Promise<void> {
|
|
12
|
+
}
|
|
13
|
+
<% } %>
|
|
14
|
+
<% if (d.tableName) { %>
|
|
15
|
+
export async function down(knex: Knex): Promise<Knex.SchemaBuilder> {
|
|
16
|
+
return knex.schema.dropTable("<%= d.tableName %>");
|
|
17
|
+
}
|
|
18
|
+
<% } else { %>
|
|
19
|
+
export async function down(knex: Knex): Promise<void> {
|
|
20
|
+
}
|
|
21
|
+
<% } %>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
exports.seed = (knex) ->
|
|
2
|
-
knex('table_name').del()
|
|
3
|
-
.then () ->
|
|
4
|
-
# Inserts seed entries
|
|
5
|
-
knex('table_name').insert([
|
|
6
|
-
{id: 1, colName: 'rowValue'}
|
|
7
|
-
{id: 2, colName: 'rowValue2'}
|
|
8
|
-
{id: 3, colName: 'rowValue3'}
|
|
9
|
-
])
|
|
1
|
+
exports.seed = (knex) ->
|
|
2
|
+
knex('table_name').del()
|
|
3
|
+
.then () ->
|
|
4
|
+
# Inserts seed entries
|
|
5
|
+
knex('table_name').insert([
|
|
6
|
+
{id: 1, colName: 'rowValue'}
|
|
7
|
+
{id: 2, colName: 'rowValue2'}
|
|
8
|
+
{id: 3, colName: 'rowValue3'}
|
|
9
|
+
])
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
provide: seed
|
|
2
|
-
seed = (knex) ->
|
|
3
|
-
;; Deletes ALL existing entries
|
|
4
|
-
knex(.table_name).del()
|
|
5
|
-
.then(() ->
|
|
6
|
-
;; Inserts seed entries
|
|
7
|
-
knex(.table_name).insert with [
|
|
8
|
-
{ id = 1, col-name = .row-value-1 }
|
|
9
|
-
{ id = 2, col-name = .row-value-2 }
|
|
10
|
-
{ id = 3, col-name = .row-value-3 }
|
|
11
|
-
]
|
|
1
|
+
provide: seed
|
|
2
|
+
seed = (knex) ->
|
|
3
|
+
;; Deletes ALL existing entries
|
|
4
|
+
knex(.table_name).del()
|
|
5
|
+
.then(() ->
|
|
6
|
+
;; Inserts seed entries
|
|
7
|
+
knex(.table_name).insert with [
|
|
8
|
+
{ id = 1, col-name = .row-value-1 }
|
|
9
|
+
{ id = 2, col-name = .row-value-2 }
|
|
10
|
+
{ id = 3, col-name = .row-value-3 }
|
|
11
|
+
]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param { import("knex").Knex } knex
|
|
3
|
-
* @returns { Promise<void> }
|
|
4
|
-
*/
|
|
5
|
-
exports.seed = async function(knex) {
|
|
6
|
-
// Deletes ALL existing entries
|
|
7
|
-
await knex('table_name').del()
|
|
8
|
-
await knex('table_name').insert([
|
|
9
|
-
{id: 1, colName: 'rowValue1'},
|
|
10
|
-
{id: 2, colName: 'rowValue2'},
|
|
11
|
-
{id: 3, colName: 'rowValue3'}
|
|
12
|
-
]);
|
|
13
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @param { import("knex").Knex } knex
|
|
3
|
+
* @returns { Promise<void> }
|
|
4
|
+
*/
|
|
5
|
+
exports.seed = async function(knex) {
|
|
6
|
+
// Deletes ALL existing entries
|
|
7
|
+
await knex('table_name').del()
|
|
8
|
+
await knex('table_name').insert([
|
|
9
|
+
{id: 1, colName: 'rowValue1'},
|
|
10
|
+
{id: 2, colName: 'rowValue2'},
|
|
11
|
+
{id: 3, colName: 'rowValue3'}
|
|
12
|
+
]);
|
|
13
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
exports.seed = (knex) ->
|
|
2
|
-
# Deletes ALL existing entries
|
|
3
|
-
knex('table_name').del()
|
|
4
|
-
.then(() ->
|
|
5
|
-
# Inserts seed entries
|
|
6
|
-
knex('table_name').insert([
|
|
7
|
-
{id: 1, colName: 'rowValue1'},
|
|
8
|
-
{id: 2, colName: 'rowValue2'},
|
|
9
|
-
{id: 3, colName: 'rowValue3'}
|
|
10
|
-
])
|
|
11
|
-
)
|
|
1
|
+
exports.seed = (knex) ->
|
|
2
|
+
# Deletes ALL existing entries
|
|
3
|
+
knex('table_name').del()
|
|
4
|
+
.then(() ->
|
|
5
|
+
# Inserts seed entries
|
|
6
|
+
knex('table_name').insert([
|
|
7
|
+
{id: 1, colName: 'rowValue1'},
|
|
8
|
+
{id: 2, colName: 'rowValue2'},
|
|
9
|
+
{id: 3, colName: 'rowValue3'}
|
|
10
|
+
])
|
|
11
|
+
)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export const seed = async (knex) => {
|
|
3
|
-
// Deletes ALL existing entries
|
|
4
|
-
await knex('table_name').del();
|
|
5
|
-
|
|
6
|
-
// Inserts seed entries
|
|
7
|
-
await knex('table_name').insert([
|
|
8
|
-
{id: 1, colName: 'rowValue1'},
|
|
9
|
-
{id: 2, colName: 'rowValue2'},
|
|
10
|
-
{id: 3, colName: 'rowValue3'}
|
|
11
|
-
]);
|
|
12
|
-
};
|
|
1
|
+
|
|
2
|
+
export const seed = async (knex) => {
|
|
3
|
+
// Deletes ALL existing entries
|
|
4
|
+
await knex('table_name').del();
|
|
5
|
+
|
|
6
|
+
// Inserts seed entries
|
|
7
|
+
await knex('table_name').insert([
|
|
8
|
+
{id: 1, colName: 'rowValue1'},
|
|
9
|
+
{id: 2, colName: 'rowValue2'},
|
|
10
|
+
{id: 3, colName: 'rowValue3'}
|
|
11
|
+
]);
|
|
12
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Knex } from "knex";
|
|
2
|
-
|
|
3
|
-
export async function seed(knex: Knex): Promise<void> {
|
|
4
|
-
// Deletes ALL existing entries
|
|
5
|
-
await knex("table_name").del();
|
|
6
|
-
|
|
7
|
-
// Inserts seed entries
|
|
8
|
-
await knex("table_name").insert([
|
|
9
|
-
{ id: 1, colName: "rowValue1" },
|
|
10
|
-
{ id: 2, colName: "rowValue2" },
|
|
11
|
-
{ id: 3, colName: "rowValue3" }
|
|
12
|
-
]);
|
|
13
|
-
};
|
|
1
|
+
import { Knex } from "knex";
|
|
2
|
+
|
|
3
|
+
export async function seed(knex: Knex): Promise<void> {
|
|
4
|
+
// Deletes ALL existing entries
|
|
5
|
+
await knex("table_name").del();
|
|
6
|
+
|
|
7
|
+
// Inserts seed entries
|
|
8
|
+
await knex("table_name").insert([
|
|
9
|
+
{ id: 1, colName: "rowValue1" },
|
|
10
|
+
{ id: 2, colName: "rowValue2" },
|
|
11
|
+
{ id: 3, colName: "rowValue3" }
|
|
12
|
+
]);
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knex",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
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": ">=16"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "npm run build:gitignore && npm run build:ts && npm run format",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js",
|
|
18
18
|
"debug:tape": "node --inspect-brk test/tape/index.js",
|
|
19
19
|
"coveralls": "nyc report --reporter=lcov",
|
|
20
|
-
"lint": "eslint --cache
|
|
21
|
-
"lint:fix": "eslint --cache --fix
|
|
20
|
+
"lint": "eslint --cache **/*.js",
|
|
21
|
+
"lint:fix": "eslint --cache --fix '**/*.js'",
|
|
22
22
|
"lint:types": "tsd && dtslint types",
|
|
23
23
|
"lint:everything": "npm run lint && npm run lint:types",
|
|
24
24
|
"lint:fix:everything": "npm run lint:fix && npm run lint:types",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"mysql": "^2.18.1",
|
|
131
131
|
"mysql2": "^3.2.0",
|
|
132
132
|
"nyc": "^15.1.0",
|
|
133
|
-
"oracledb": "^
|
|
133
|
+
"oracledb": "^6.1.0",
|
|
134
134
|
"pg": "^8.8.0",
|
|
135
135
|
"pg-query-stream": "^4.2.4",
|
|
136
136
|
"prettier": "2.8.7",
|
|
@@ -1,82 +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"
|
|
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"
|