@koalarx/nest 3.1.14 → 3.1.16
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/core/database/repository.base.js +31 -10
- package/core/utils/generate-prisma-include-schema.js +16 -10
- package/package.json +1 -1
- package/test/utils/create-e2e-database.d.ts +6 -1
- package/test/utils/create-e2e-database.js +4 -13
- package/test/utils/e2e-database-client.d.ts +7 -0
- package/test/utils/e2e-database-client.js +12 -0
- package/tsconfig.lib.tsbuildinfo +1 -1
- package/test/utils/drop-e2e-database.d.ts +0 -2
- package/test/utils/drop-e2e-database.js +0 -33
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dropE2EDatabase = dropE2EDatabase;
|
|
4
|
-
require("dotenv/config");
|
|
5
|
-
const pg_1 = require("pg");
|
|
6
|
-
async function dropE2EDatabase(schemaId) {
|
|
7
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
8
|
-
const baseUrl = new URL(process.env.DATABASE_URL || '');
|
|
9
|
-
baseUrl.pathname = '/postgres';
|
|
10
|
-
const pool = new pg_1.Pool({
|
|
11
|
-
connectionString: baseUrl.toString(),
|
|
12
|
-
idleTimeoutMillis: 100,
|
|
13
|
-
});
|
|
14
|
-
try {
|
|
15
|
-
await pool.query(`
|
|
16
|
-
SELECT pg_terminate_backend(pg_stat_activity.pid)
|
|
17
|
-
FROM pg_stat_activity
|
|
18
|
-
WHERE pg_stat_activity.datname = '${schemaId}'
|
|
19
|
-
AND pid <> pg_backend_pid()
|
|
20
|
-
`);
|
|
21
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
22
|
-
await pool.query(`DROP DATABASE IF EXISTS "${schemaId}"`);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
}
|
|
26
|
-
finally {
|
|
27
|
-
try {
|
|
28
|
-
await pool.end();
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|