velocious 1.0.29 → 1.0.30
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/package.json +5 -2
- package/peak_flow.yml +21 -0
- package/spec/cli/commands/db/create-spec.js +14 -2
- package/spec/cli/commands/db/migrate-spec.js +56 -25
- package/spec/database/drivers/mysql/connection-spec.js +2 -2
- package/spec/dummy/index.js +8 -7
- package/spec/dummy/src/config/configuration.example.js +25 -3
- package/spec/dummy/src/config/configuration.mariadb.js +97 -0
- package/spec/dummy/src/config/configuration.peakflow.mariadb.js +26 -3
- package/spec/dummy/src/config/configuration.peakflow.mssql.js +75 -0
- package/spec/dummy/src/config/configuration.peakflow.sqlite.js +27 -3
- package/spec/dummy/src/config/configuration.sqlite.js +58 -4
- package/spec/dummy/src/database/migrations/20250903112845-create-accounts.js +18 -0
- package/src/cli/commands/db/create.js +25 -15
- package/src/cli/commands/db/migrate.js +4 -82
- package/src/cli/commands/db/reset.js +40 -0
- package/src/configuration.js +71 -18
- package/src/database/drivers/base.js +97 -13
- package/src/database/drivers/mssql/column.js +10 -0
- package/src/database/drivers/mssql/connect-connection.js +12 -0
- package/src/database/drivers/mssql/foreign-key.js +13 -0
- package/src/database/drivers/mssql/index.js +216 -0
- package/src/database/drivers/mssql/options.js +43 -0
- package/src/database/drivers/mssql/query-parser.js +4 -0
- package/src/database/drivers/mssql/sql/create-database.js +28 -0
- package/src/database/drivers/mssql/sql/create-index.js +4 -0
- package/src/database/drivers/mssql/sql/create-table.js +4 -0
- package/src/database/drivers/mssql/sql/delete.js +19 -0
- package/src/database/drivers/mssql/sql/drop-table.js +4 -0
- package/src/database/drivers/mssql/sql/insert.js +4 -0
- package/src/database/drivers/mssql/sql/update.js +31 -0
- package/src/database/drivers/mssql/table.js +65 -0
- package/src/database/drivers/mysql/index.js +29 -18
- package/src/database/drivers/mysql/query.js +1 -1
- package/src/database/drivers/mysql/sql/drop-table.js +4 -0
- package/src/database/drivers/sqlite/base.js +25 -23
- package/src/database/drivers/sqlite/index.native.js +10 -1
- package/src/database/drivers/sqlite/sql/drop-table.js +4 -0
- package/src/database/initializer-from-require-context.js +3 -1
- package/src/database/migration/index.js +32 -23
- package/src/database/migrator.js +176 -27
- package/src/database/pool/async-tracked-multi-connection.js +2 -3
- package/src/database/pool/base.js +15 -3
- package/src/database/query/base.js +24 -4
- package/src/database/query/create-database-base.js +1 -3
- package/src/database/query/create-index-base.js +13 -4
- package/src/database/query/create-table-base.js +27 -11
- package/src/database/query/drop-table-base.js +39 -0
- package/src/database/query/index.js +5 -1
- package/src/database/query/insert-base.js +31 -6
- package/src/database/query-parser/limit-parser.js +11 -2
- package/src/database/query-parser/options.js +20 -8
- package/src/database/record/index.js +19 -3
- package/src/database/use-database.js +1 -1
- package/src/routes/resolver.js +1 -1
- package/src/templates/configuration.js +36 -3
- package/src/testing/test-runner.js +1 -1
- package/src/utils/nest-callbacks.js +15 -0
- package/src/big-brother.js +0 -37
- package/src/database/migrate-from-require-context.js +0 -72
- package/src/spec/index.js +0 -5
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"velocious": "bin/velocious.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "velocious",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.30",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "jasmine",
|
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
"description": "",
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"jasmine": "^5.0.2",
|
|
26
|
+
"mssql": "^11.0.1",
|
|
26
27
|
"mysql": "^2.18.1",
|
|
27
28
|
"node-fetch": "^3.3.1",
|
|
28
29
|
"require-context": "^1.1.0",
|
|
29
30
|
"sqlite": "^5.1.1",
|
|
30
|
-
"sqlite3": "^5.1.7"
|
|
31
|
+
"sqlite3": "^5.1.7",
|
|
32
|
+
"tedious": "^18.6.1",
|
|
33
|
+
"uniqunize": "^1.0.1"
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
36
|
"bcryptjs": "^3.0.2",
|
package/peak_flow.yml
CHANGED
|
@@ -6,6 +6,8 @@ before_install:
|
|
|
6
6
|
- sudo apt-get install -y nodejs
|
|
7
7
|
before_script:
|
|
8
8
|
- npm install
|
|
9
|
+
environment:
|
|
10
|
+
NODE_ENV: test
|
|
9
11
|
services:
|
|
10
12
|
mariadb:
|
|
11
13
|
environment:
|
|
@@ -18,15 +20,34 @@ services:
|
|
|
18
20
|
- 3306
|
|
19
21
|
mem_limit: 4096m
|
|
20
22
|
restart_policy: on-failure
|
|
23
|
+
mssql:
|
|
24
|
+
environment:
|
|
25
|
+
ACCEPT_EULA: Y
|
|
26
|
+
MSSQL_PID: Developer
|
|
27
|
+
MSSQL_SA_PASSWORD: Super-Secret-Password
|
|
28
|
+
image: mcr.microsoft.com/mssql/server:2022-latest
|
|
29
|
+
expose:
|
|
30
|
+
- 1433
|
|
31
|
+
mem_limit: 4096m
|
|
32
|
+
restart_policy: on-failure
|
|
21
33
|
builds:
|
|
22
34
|
build_1:
|
|
23
35
|
name: MariaDB
|
|
24
36
|
script:
|
|
25
37
|
- cp spec/dummy/src/config/configuration.peakflow.mariadb.js spec/dummy/src/config/configuration.js
|
|
38
|
+
- cd spec/dummy && npx velocious db:create
|
|
26
39
|
- wait-for-it mariadb:3306
|
|
27
40
|
- npm test
|
|
28
41
|
build_2:
|
|
42
|
+
name: MS-SQL
|
|
43
|
+
script:
|
|
44
|
+
- wait-for-it mssql:1433
|
|
45
|
+
- cp spec/dummy/src/config/configuration.peakflow.mssql.js spec/dummy/src/config/configuration.js
|
|
46
|
+
- cd spec/dummy && npx velocious db:create
|
|
47
|
+
- npm test
|
|
48
|
+
build_3:
|
|
29
49
|
name: SQLite
|
|
30
50
|
script:
|
|
31
51
|
- cp spec/dummy/src/config/configuration.peakflow.sqlite.js spec/dummy/src/config/configuration.js
|
|
52
|
+
- cd spec/dummy && npx velocious db:create
|
|
32
53
|
- npm test
|
|
@@ -14,7 +14,19 @@ describe("Cli - Commands - db:create", () => {
|
|
|
14
14
|
expect(result).toEqual(
|
|
15
15
|
[
|
|
16
16
|
{
|
|
17
|
-
createSchemaMigrationsTableSql: 'CREATE TABLE IF NOT EXISTS schema_migrations (`version` VARCHAR(255) PRIMARY KEY NOT NULL)'
|
|
17
|
+
createSchemaMigrationsTableSql: 'CREATE TABLE IF NOT EXISTS `schema_migrations` (`version` VARCHAR(255) PRIMARY KEY NOT NULL)'
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
)
|
|
21
|
+
} else if (cli.getConfiguration().getDatabaseType() == "mssql") {
|
|
22
|
+
expect(result).toEqual(
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
|
+
databaseName: 'velocious_test',
|
|
26
|
+
sql: "IF NOT EXISTS(SELECT * FROM [sys].[databases] WHERE [name] = 'velocious_test') BEGIN CREATE DATABASE [velocious_test] END"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
createSchemaMigrationsTableSql: "IF NOT EXISTS(SELECT * FROM [sysobjects] WHERE [name] = 'schema_migrations' AND [xtype] = 'U') BEGIN CREATE TABLE [schema_migrations] ([version] VARCHAR(255) PRIMARY KEY NOT NULL) END"
|
|
18
30
|
}
|
|
19
31
|
]
|
|
20
32
|
)
|
|
@@ -26,7 +38,7 @@ describe("Cli - Commands - db:create", () => {
|
|
|
26
38
|
sql: 'CREATE DATABASE IF NOT EXISTS `velocious_test`'
|
|
27
39
|
},
|
|
28
40
|
{
|
|
29
|
-
createSchemaMigrationsTableSql: 'CREATE TABLE IF NOT EXISTS schema_migrations (`version` VARCHAR(255) PRIMARY KEY NOT NULL)'
|
|
41
|
+
createSchemaMigrationsTableSql: 'CREATE TABLE IF NOT EXISTS `schema_migrations` (`version` VARCHAR(255) PRIMARY KEY NOT NULL)'
|
|
30
42
|
}
|
|
31
43
|
]
|
|
32
44
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Cli from "../../../../src/cli/index.js"
|
|
2
2
|
import dummyDirectory from "../../../dummy/dummy-directory.js"
|
|
3
|
+
import uniqunize from "uniqunize"
|
|
3
4
|
|
|
4
5
|
describe("Cli - Commands - db:migrate", () => {
|
|
5
6
|
it("runs migrations", async () => {
|
|
@@ -12,46 +13,76 @@ describe("Cli - Commands - db:migrate", () => {
|
|
|
12
13
|
|
|
13
14
|
await cli.loadConfiguration()
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
let defaultDatabaseType, defaultSchemaMigrations = [], projectForeignKey = [], tablesResult = []
|
|
16
17
|
|
|
17
|
-
await
|
|
18
|
-
|
|
19
|
-
await db.query("DROP TABLE IF EXISTS project_translations")
|
|
20
|
-
await db.query("DROP TABLE IF EXISTS projects")
|
|
21
|
-
await db.query("DROP TABLE IF EXISTS schema_migrations")
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
await cli.execute()
|
|
18
|
+
await cli.configuration.withConnections(async (dbs) => {
|
|
19
|
+
defaultDatabaseType = dbs.default.getType()
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
const tableNames = ["accounts", "tasks", "project_translations", "projects", "schema_migrations"]
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
for (const tableName of tableNames) {
|
|
24
|
+
await dbs.default.dropTable(tableName, {ifExists: true})
|
|
25
|
+
await dbs.mssql.dropTable(tableName, {ifExists: true})
|
|
26
|
+
}
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
await cli.execute()
|
|
32
29
|
|
|
33
|
-
const table = await
|
|
30
|
+
const table = await dbs.default.getTableByName("tasks")
|
|
34
31
|
const foreignKeys = await table.getForeignKeys()
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
for (const foreignKey of foreignKeys) {
|
|
34
|
+
if (foreignKey.getColumnName() == "project_id") {
|
|
35
|
+
projectForeignKey = foreignKey
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const db of Object.values(dbs)) {
|
|
40
|
+
const schemaMigrations = await db.query("SELECT * FROM schema_migrations ORDER BY version")
|
|
41
|
+
|
|
42
|
+
for (const schemaMigration of schemaMigrations) {
|
|
43
|
+
defaultSchemaMigrations.push(schemaMigration.version)
|
|
44
|
+
}
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
const tables = await db.getTables()
|
|
47
|
+
|
|
48
|
+
for (const table of tables) {
|
|
49
|
+
tablesResult.push(table.getName())
|
|
50
|
+
}
|
|
51
|
+
}
|
|
39
52
|
})
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
[
|
|
43
|
-
"project_translations",
|
|
44
|
-
"projects",
|
|
45
|
-
"schema_migrations",
|
|
46
|
-
"tasks"
|
|
47
|
-
]
|
|
48
|
-
)
|
|
54
|
+
|
|
49
55
|
|
|
50
56
|
expect(projectForeignKey.getTableName()).toEqual("tasks")
|
|
51
57
|
expect(projectForeignKey.getColumnName()).toEqual("project_id")
|
|
52
58
|
expect(projectForeignKey.getReferencedTableName()).toEqual("projects")
|
|
53
59
|
expect(projectForeignKey.getReferencedColumnName()).toEqual("id")
|
|
54
60
|
|
|
55
|
-
|
|
61
|
+
if (defaultDatabaseType == "mssql") {
|
|
62
|
+
expect(uniqunize(tablesResult.sort())).toEqual(
|
|
63
|
+
[
|
|
64
|
+
"accounts",
|
|
65
|
+
"project_translations",
|
|
66
|
+
"projects",
|
|
67
|
+
"schema_migrations",
|
|
68
|
+
"tasks"
|
|
69
|
+
]
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
expect(uniqunize(defaultSchemaMigrations.sort())).toEqual(["20230728075328", "20230728075329", "20250605133926", "20250903112845"])
|
|
73
|
+
} else {
|
|
74
|
+
expect(tablesResult.sort()).toEqual(
|
|
75
|
+
[
|
|
76
|
+
"accounts",
|
|
77
|
+
"project_translations",
|
|
78
|
+
"projects",
|
|
79
|
+
"schema_migrations",
|
|
80
|
+
"schema_migrations",
|
|
81
|
+
"tasks"
|
|
82
|
+
]
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
expect(defaultSchemaMigrations.sort()).toEqual(["20230728075328", "20230728075329", "20250605133926", "20250903112845"])
|
|
86
|
+
}
|
|
56
87
|
})
|
|
57
88
|
})
|
|
@@ -2,11 +2,11 @@ import DatabaseDriversMysql from "../../../../src/database/drivers/mysql/index.j
|
|
|
2
2
|
import configuration from "../../../dummy/src/config/configuration.js"
|
|
3
3
|
import {digg} from "diggerize"
|
|
4
4
|
|
|
5
|
-
const mysqlConfig = digg(configuration, "database", "
|
|
5
|
+
const mysqlConfig = digg(configuration, "database", "test", "default")
|
|
6
6
|
|
|
7
7
|
describe("Database - Drivers - Mysql - Connection", () => {
|
|
8
8
|
it("connects", async () => {
|
|
9
|
-
if (configuration.getDatabaseType() != "sqlite") {
|
|
9
|
+
if (configuration.getDatabaseType() != "sqlite" && configuration.getDatabaseType() != "mssql") {
|
|
10
10
|
const mysql = new DatabaseDriversMysql(mysqlConfig)
|
|
11
11
|
|
|
12
12
|
await mysql.connect()
|
package/spec/dummy/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Application from "../../src/application.js"
|
|
2
|
+
import {digg} from "diggerize"
|
|
2
3
|
import dummyConfiguration from "./src/config/configuration.js"
|
|
3
4
|
import Migration from "../../src/database/migration/index.js"
|
|
4
5
|
|
|
@@ -14,14 +15,14 @@ export default class Dummy {
|
|
|
14
15
|
static async prepare() {
|
|
15
16
|
dummyConfiguration.setCurrent()
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
await dummyConfiguration.withConnections(async (dbs) => {
|
|
19
|
+
const db = digg(dbs, "default")
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
await db.
|
|
21
|
-
await db.
|
|
22
|
-
await db.query("DROP TABLE IF EXISTS projects")
|
|
21
|
+
await db.dropTable("tasks", {ifExists: true})
|
|
22
|
+
await db.dropTable("project_translations", {ifExists: true})
|
|
23
|
+
await db.dropTable("projects", {ifExists: true})
|
|
23
24
|
|
|
24
|
-
const migration = new Migration({configuration: dummyConfiguration})
|
|
25
|
+
const migration = new Migration({configuration: dummyConfiguration, databaseIdentifier: "default", db})
|
|
25
26
|
|
|
26
27
|
await migration.createTable("projects", (t) => {
|
|
27
28
|
t.timestamps()
|
|
@@ -51,7 +52,7 @@ export default class Dummy {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
async run(callback) {
|
|
54
|
-
await dummyConfiguration.
|
|
55
|
+
await dummyConfiguration.withConnections(async () => {
|
|
55
56
|
await Dummy.prepare()
|
|
56
57
|
await this.start()
|
|
57
58
|
|
|
@@ -9,8 +9,30 @@ import requireContext from "require-context"
|
|
|
9
9
|
|
|
10
10
|
export default new Configuration({
|
|
11
11
|
database: {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
development: {
|
|
13
|
+
default: {
|
|
14
|
+
driver: MysqlDriver,
|
|
15
|
+
poolType: AsyncTrackedMultiConnection,
|
|
16
|
+
type: "mysql",
|
|
17
|
+
host: "mariadb",
|
|
18
|
+
username: "username",
|
|
19
|
+
password: "password",
|
|
20
|
+
database: "velocious_development"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
production: {
|
|
24
|
+
default: {
|
|
25
|
+
driver: MysqlDriver,
|
|
26
|
+
poolType: AsyncTrackedMultiConnection,
|
|
27
|
+
type: "mysql",
|
|
28
|
+
host: "mariadb",
|
|
29
|
+
username: "username",
|
|
30
|
+
password: "password",
|
|
31
|
+
database: "velocious_production"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
test: {
|
|
35
|
+
default: {
|
|
14
36
|
driver: MysqlDriver,
|
|
15
37
|
poolType: AsyncTrackedMultiConnection,
|
|
16
38
|
type: "mysql",
|
|
@@ -27,7 +49,7 @@ export default new Configuration({
|
|
|
27
49
|
const requireContextModels = requireContext(modelsPath, true, /^(.+)\.js$/)
|
|
28
50
|
const initializerFromRequireContext = new InitializerFromRequireContext({requireContext: requireContextModels})
|
|
29
51
|
|
|
30
|
-
await configuration.
|
|
52
|
+
await configuration.withConnections(async () => {
|
|
31
53
|
await initializerFromRequireContext.initialize({configuration})
|
|
32
54
|
})
|
|
33
55
|
},
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import AsyncTrackedMultiConnection from "../../../../src/database/pool/async-tracked-multi-connection.js"
|
|
2
|
+
import Configuration from "../../../../src/configuration.js"
|
|
3
|
+
import dummyDirectory from "../../dummy-directory.js"
|
|
4
|
+
import fs from "fs/promises"
|
|
5
|
+
import InitializerFromRequireContext from "../../../../src/database/initializer-from-require-context.js"
|
|
6
|
+
import MssqlDriver from "../../../../src/database/drivers/mssql/index.js"
|
|
7
|
+
import MysqlDriver from "../../../../src/database/drivers/mysql/index.js"
|
|
8
|
+
import path from "path"
|
|
9
|
+
import requireContext from "require-context"
|
|
10
|
+
|
|
11
|
+
export default new Configuration({
|
|
12
|
+
database: {
|
|
13
|
+
development: {
|
|
14
|
+
default: {
|
|
15
|
+
driver: MysqlDriver,
|
|
16
|
+
poolType: AsyncTrackedMultiConnection,
|
|
17
|
+
type: "mysql",
|
|
18
|
+
host: "mariadb",
|
|
19
|
+
username: "dev",
|
|
20
|
+
password: "Eid7Eip6iof2weive7yaeshe8eu2Nei4",
|
|
21
|
+
database: "velocious_test"
|
|
22
|
+
},
|
|
23
|
+
mssql: {
|
|
24
|
+
driver: MssqlDriver,
|
|
25
|
+
poolType: AsyncTrackedMultiConnection,
|
|
26
|
+
type: "mssql",
|
|
27
|
+
database: "velocious_development",
|
|
28
|
+
useDatabase: "velocious_development",
|
|
29
|
+
sqlConfig: {
|
|
30
|
+
user: "sa",
|
|
31
|
+
password: "Super-Secret-Password",
|
|
32
|
+
database: "velocious_development",
|
|
33
|
+
server: "6.0.0.8",
|
|
34
|
+
pool: {
|
|
35
|
+
max: 10,
|
|
36
|
+
min: 0,
|
|
37
|
+
idleTimeoutMillis: 30000
|
|
38
|
+
},
|
|
39
|
+
options: {
|
|
40
|
+
encrypt: true, // for azure
|
|
41
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
test: {
|
|
47
|
+
default: {
|
|
48
|
+
driver: MysqlDriver,
|
|
49
|
+
poolType: AsyncTrackedMultiConnection,
|
|
50
|
+
type: "mysql",
|
|
51
|
+
host: "mariadb",
|
|
52
|
+
username: "dev",
|
|
53
|
+
password: "Eid7Eip6iof2weive7yaeshe8eu2Nei4",
|
|
54
|
+
database: "velocious_test"
|
|
55
|
+
},
|
|
56
|
+
mssql: {
|
|
57
|
+
driver: MssqlDriver,
|
|
58
|
+
poolType: AsyncTrackedMultiConnection,
|
|
59
|
+
type: "mssql",
|
|
60
|
+
database: "velocious_development",
|
|
61
|
+
useDatabase: "velocious_development",
|
|
62
|
+
sqlConfig: {
|
|
63
|
+
user: "sa",
|
|
64
|
+
password: "Super-Secret-Password",
|
|
65
|
+
database: "velocious_development",
|
|
66
|
+
server: "6.0.0.8",
|
|
67
|
+
pool: {
|
|
68
|
+
max: 10,
|
|
69
|
+
min: 0,
|
|
70
|
+
idleTimeoutMillis: 30000
|
|
71
|
+
},
|
|
72
|
+
options: {
|
|
73
|
+
encrypt: true, // for azure
|
|
74
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
debug: false,
|
|
81
|
+
directory: dummyDirectory(),
|
|
82
|
+
initializeModels: async ({configuration}) => {
|
|
83
|
+
const modelsPath = await fs.realpath(`${path.dirname(import.meta.dirname)}/../src/models`)
|
|
84
|
+
const requireContextModels = requireContext(modelsPath, true, /^(.+)\.js$/)
|
|
85
|
+
const initializerFromRequireContext = new InitializerFromRequireContext({requireContext: requireContextModels})
|
|
86
|
+
|
|
87
|
+
await configuration.withConnections(async () => {
|
|
88
|
+
await initializerFromRequireContext.initialize({configuration})
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
locale: () => "en",
|
|
92
|
+
localeFallbacks: {
|
|
93
|
+
de: ["de", "en"],
|
|
94
|
+
en: ["en", "de"]
|
|
95
|
+
},
|
|
96
|
+
locales: ["de", "en"]
|
|
97
|
+
})
|
|
@@ -3,14 +3,15 @@ import Configuration from "../../../../src/configuration.js"
|
|
|
3
3
|
import dummyDirectory from "../../dummy-directory.js"
|
|
4
4
|
import fs from "fs/promises"
|
|
5
5
|
import InitializerFromRequireContext from "../../../../src/database/initializer-from-require-context.js"
|
|
6
|
+
import MssqlDriver from "../../../../src/database/drivers/mssql/index.js"
|
|
6
7
|
import MysqlDriver from "../../../../src/database/drivers/mysql/index.js"
|
|
7
8
|
import path from "path"
|
|
8
9
|
import requireContext from "require-context"
|
|
9
10
|
|
|
10
11
|
export default new Configuration({
|
|
11
12
|
database: {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
test: {
|
|
14
|
+
default: {
|
|
14
15
|
driver: MysqlDriver,
|
|
15
16
|
poolType: AsyncTrackedMultiConnection,
|
|
16
17
|
type: "mysql",
|
|
@@ -19,6 +20,28 @@ export default new Configuration({
|
|
|
19
20
|
password: "password",
|
|
20
21
|
database: "velocious_test",
|
|
21
22
|
useDatabase: "velocious_test"
|
|
23
|
+
},
|
|
24
|
+
mssql: {
|
|
25
|
+
driver: MssqlDriver,
|
|
26
|
+
poolType: AsyncTrackedMultiConnection,
|
|
27
|
+
type: "mssql",
|
|
28
|
+
database: "velocious_test",
|
|
29
|
+
useDatabase: "default",
|
|
30
|
+
sqlConfig: {
|
|
31
|
+
user: "sa",
|
|
32
|
+
password: "Super-Secret-Password",
|
|
33
|
+
database: "velocious_test",
|
|
34
|
+
server: "mssql",
|
|
35
|
+
pool: {
|
|
36
|
+
max: 10,
|
|
37
|
+
min: 0,
|
|
38
|
+
idleTimeoutMillis: 30000
|
|
39
|
+
},
|
|
40
|
+
options: {
|
|
41
|
+
encrypt: true, // for azure
|
|
42
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
43
|
+
}
|
|
44
|
+
}
|
|
22
45
|
}
|
|
23
46
|
}
|
|
24
47
|
},
|
|
@@ -28,7 +51,7 @@ export default new Configuration({
|
|
|
28
51
|
const requireContextModels = requireContext(modelsPath, true, /^(.+)\.js$/)
|
|
29
52
|
const initializerFromRequireContext = new InitializerFromRequireContext({requireContext: requireContextModels})
|
|
30
53
|
|
|
31
|
-
await configuration.
|
|
54
|
+
await configuration.withConnections(async () => {
|
|
32
55
|
await initializerFromRequireContext.initialize({configuration})
|
|
33
56
|
})
|
|
34
57
|
},
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import AsyncTrackedMultiConnection from "../../../../src/database/pool/async-tracked-multi-connection.js"
|
|
2
|
+
import Configuration from "../../../../src/configuration.js"
|
|
3
|
+
import dummyDirectory from "../../dummy-directory.js"
|
|
4
|
+
import fs from "fs/promises"
|
|
5
|
+
import InitializerFromRequireContext from "../../../../src/database/initializer-from-require-context.js"
|
|
6
|
+
import MssqlDriver from "../../../../src/database/drivers/mssql/index.js"
|
|
7
|
+
import path from "path"
|
|
8
|
+
import requireContext from "require-context"
|
|
9
|
+
|
|
10
|
+
export default new Configuration({
|
|
11
|
+
database: {
|
|
12
|
+
test: {
|
|
13
|
+
default: {
|
|
14
|
+
driver: MssqlDriver,
|
|
15
|
+
poolType: AsyncTrackedMultiConnection,
|
|
16
|
+
type: "mssql",
|
|
17
|
+
database: "velocious_test",
|
|
18
|
+
useDatabase: "default",
|
|
19
|
+
sqlConfig: {
|
|
20
|
+
user: "sa",
|
|
21
|
+
password: "Super-Secret-Password",
|
|
22
|
+
database: "velocious_test",
|
|
23
|
+
server: "mssql",
|
|
24
|
+
pool: {
|
|
25
|
+
max: 10,
|
|
26
|
+
min: 0,
|
|
27
|
+
idleTimeoutMillis: 30000
|
|
28
|
+
},
|
|
29
|
+
options: {
|
|
30
|
+
encrypt: true, // for azure
|
|
31
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
mssql: {
|
|
36
|
+
driver: MssqlDriver,
|
|
37
|
+
poolType: AsyncTrackedMultiConnection,
|
|
38
|
+
type: "mssql",
|
|
39
|
+
database: "velocious_test",
|
|
40
|
+
useDatabase: "default",
|
|
41
|
+
sqlConfig: {
|
|
42
|
+
user: "sa",
|
|
43
|
+
password: "Super-Secret-Password",
|
|
44
|
+
database: "velocious_test",
|
|
45
|
+
server: "mssql",
|
|
46
|
+
pool: {
|
|
47
|
+
max: 10,
|
|
48
|
+
min: 0,
|
|
49
|
+
idleTimeoutMillis: 30000
|
|
50
|
+
},
|
|
51
|
+
options: {
|
|
52
|
+
encrypt: true, // for azure
|
|
53
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
directory: dummyDirectory(),
|
|
60
|
+
initializeModels: async ({configuration}) => {
|
|
61
|
+
const modelsPath = await fs.realpath(`${path.dirname(import.meta.dirname)}/../src/models`)
|
|
62
|
+
const requireContextModels = requireContext(modelsPath, true, /^(.+)\.js$/)
|
|
63
|
+
const initializerFromRequireContext = new InitializerFromRequireContext({requireContext: requireContextModels})
|
|
64
|
+
|
|
65
|
+
await configuration.withConnections(async () => {
|
|
66
|
+
await initializerFromRequireContext.initialize({configuration})
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
locale: () => "en",
|
|
70
|
+
localeFallbacks: {
|
|
71
|
+
de: ["de", "en"],
|
|
72
|
+
en: ["en", "de"]
|
|
73
|
+
},
|
|
74
|
+
locales: ["de", "en"]
|
|
75
|
+
})
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import AsyncTrackedMultiConnection from "../../../../src/database/pool/async-tracked-multi-connection.js"
|
|
1
2
|
import Configuration from "../../../../src/configuration.js"
|
|
2
3
|
import dummyDirectory from "../../dummy-directory.js"
|
|
3
4
|
import fs from "fs/promises"
|
|
4
5
|
import InitializerFromRequireContext from "../../../../src/database/initializer-from-require-context.js"
|
|
6
|
+
import MssqlDriver from "../../../../src/database/drivers/mssql/index.js"
|
|
5
7
|
import SqliteDriver from "../../../../src/database/drivers/sqlite/index.js"
|
|
6
8
|
import path from "path"
|
|
7
9
|
import requireContext from "require-context"
|
|
@@ -9,12 +11,34 @@ import SingleMultiUsePool from "../../../../src/database/pool/single-multi-use.j
|
|
|
9
11
|
|
|
10
12
|
export default new Configuration({
|
|
11
13
|
database: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
test: {
|
|
15
|
+
default: {
|
|
14
16
|
driver: SqliteDriver,
|
|
15
17
|
poolType: SingleMultiUsePool,
|
|
16
18
|
type: "sqlite",
|
|
17
19
|
name: "test-db"
|
|
20
|
+
},
|
|
21
|
+
mssql: {
|
|
22
|
+
driver: MssqlDriver,
|
|
23
|
+
poolType: AsyncTrackedMultiConnection,
|
|
24
|
+
type: "mssql",
|
|
25
|
+
database: "velocious_test",
|
|
26
|
+
useDatabase: "default",
|
|
27
|
+
sqlConfig: {
|
|
28
|
+
user: "sa",
|
|
29
|
+
password: "Super-Secret-Password",
|
|
30
|
+
database: "velocious_test",
|
|
31
|
+
server: "mssql",
|
|
32
|
+
pool: {
|
|
33
|
+
max: 10,
|
|
34
|
+
min: 0,
|
|
35
|
+
idleTimeoutMillis: 30000
|
|
36
|
+
},
|
|
37
|
+
options: {
|
|
38
|
+
encrypt: true, // for azure
|
|
39
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
40
|
+
}
|
|
41
|
+
}
|
|
18
42
|
}
|
|
19
43
|
}
|
|
20
44
|
},
|
|
@@ -24,7 +48,7 @@ export default new Configuration({
|
|
|
24
48
|
const requireContextModels = requireContext(modelsPath, true, /^(.+)\.js$/)
|
|
25
49
|
const initializerFromRequireContext = new InitializerFromRequireContext({requireContext: requireContextModels})
|
|
26
50
|
|
|
27
|
-
await configuration.
|
|
51
|
+
await configuration.withConnections(async () => {
|
|
28
52
|
await initializerFromRequireContext.initialize({configuration})
|
|
29
53
|
})
|
|
30
54
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import AsyncTrackedMultiConnection from "../../../../src/database/pool/async-tracked-multi-connection.js"
|
|
1
2
|
import Configuration from "../../../../src/configuration.js"
|
|
2
3
|
import dummyDirectory from "../../dummy-directory.js"
|
|
3
4
|
import fs from "fs/promises"
|
|
4
5
|
import InitializerFromRequireContext from "../../../../src/database/initializer-from-require-context.js"
|
|
6
|
+
import MssqlDriver from "../../../../src/database/drivers/mssql/index.js"
|
|
5
7
|
import path from "path"
|
|
6
8
|
import requireContext from "require-context"
|
|
7
9
|
import SqliteDriver from "../../../../src/database/drivers/sqlite/index.js"
|
|
@@ -9,12 +11,64 @@ import SingleMultiUsePool from "../../../../src/database/pool/single-multi-use.j
|
|
|
9
11
|
|
|
10
12
|
export default new Configuration({
|
|
11
13
|
database: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
development: {
|
|
15
|
+
default: {
|
|
14
16
|
driver: SqliteDriver,
|
|
15
17
|
poolType: SingleMultiUsePool,
|
|
16
18
|
type: "sqlite",
|
|
17
|
-
name: "test-db"
|
|
19
|
+
name: "test-db-development"
|
|
20
|
+
},
|
|
21
|
+
mssql: {
|
|
22
|
+
driver: MssqlDriver,
|
|
23
|
+
poolType: AsyncTrackedMultiConnection,
|
|
24
|
+
type: "mssql",
|
|
25
|
+
database: "velocious_development",
|
|
26
|
+
useDatabase: "velocious_development",
|
|
27
|
+
sqlConfig: {
|
|
28
|
+
user: "sa",
|
|
29
|
+
password: "Super-Secret-Password",
|
|
30
|
+
database: "velocious_development",
|
|
31
|
+
server: "6.0.0.8",
|
|
32
|
+
pool: {
|
|
33
|
+
max: 10,
|
|
34
|
+
min: 0,
|
|
35
|
+
idleTimeoutMillis: 30000
|
|
36
|
+
},
|
|
37
|
+
options: {
|
|
38
|
+
encrypt: true, // for azure
|
|
39
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
test: {
|
|
45
|
+
default: {
|
|
46
|
+
driver: SqliteDriver,
|
|
47
|
+
poolType: SingleMultiUsePool,
|
|
48
|
+
type: "sqlite",
|
|
49
|
+
name: "test-db-test"
|
|
50
|
+
},
|
|
51
|
+
mssql: {
|
|
52
|
+
driver: MssqlDriver,
|
|
53
|
+
poolType: AsyncTrackedMultiConnection,
|
|
54
|
+
type: "mssql",
|
|
55
|
+
database: "velocious_test",
|
|
56
|
+
useDatabase: "velocious_test",
|
|
57
|
+
sqlConfig: {
|
|
58
|
+
user: "sa",
|
|
59
|
+
password: "Super-Secret-Password",
|
|
60
|
+
database: "velocious_test",
|
|
61
|
+
server: "6.0.0.8",
|
|
62
|
+
pool: {
|
|
63
|
+
max: 10,
|
|
64
|
+
min: 0,
|
|
65
|
+
idleTimeoutMillis: 30000
|
|
66
|
+
},
|
|
67
|
+
options: {
|
|
68
|
+
encrypt: true, // for azure
|
|
69
|
+
trustServerCertificate: true // change to true for local dev / self-signed certs
|
|
70
|
+
}
|
|
71
|
+
}
|
|
18
72
|
}
|
|
19
73
|
}
|
|
20
74
|
},
|
|
@@ -24,7 +78,7 @@ export default new Configuration({
|
|
|
24
78
|
const requireContextModels = requireContext(modelsPath, true, /^(.+)\.js$/)
|
|
25
79
|
const initializerFromRequireContext = new InitializerFromRequireContext({requireContext: requireContextModels})
|
|
26
80
|
|
|
27
|
-
await configuration.
|
|
81
|
+
await configuration.withConnections(async () => {
|
|
28
82
|
await initializerFromRequireContext.initialize({configuration})
|
|
29
83
|
})
|
|
30
84
|
},
|