core-services-sdk 1.3.72 → 1.3.73

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-services-sdk",
3
- "version": "1.3.72",
3
+ "version": "1.3.73",
4
4
  "main": "src/index.js",
5
5
  "type": "module",
6
6
  "types": "types/index.d.ts",
@@ -35,24 +35,33 @@ export async function validateSchema({
35
35
  connection,
36
36
  log = { info: console.info },
37
37
  }) {
38
- const db = connectToPg(connection)
38
+ const db = connectToPg(connection, {
39
+ pool: {
40
+ min: 0,
41
+ max: 1,
42
+ },
43
+ })
39
44
 
40
- const missingTables = []
45
+ try {
46
+ const missingTables = []
41
47
 
42
- for (const table of tables) {
43
- const exists = await db.schema.hasTable(table)
44
- if (!exists) {
45
- missingTables.push(table)
48
+ for (const table of tables) {
49
+ const exists = await db.schema.hasTable(table)
50
+ if (!exists) {
51
+ missingTables.push(table)
52
+ }
46
53
  }
47
- }
48
54
 
49
- if (missingTables.length > 0) {
50
- throw new Error(
51
- `Missing the following tables: ${missingTables.join(', ')}. Did you run migrations?`,
52
- )
53
- }
55
+ if (missingTables.length > 0) {
56
+ throw new Error(
57
+ `Missing the following tables: ${missingTables.join(', ')}. Did you run migrations?`,
58
+ )
59
+ }
54
60
 
55
- if (tables.length) {
56
- log.info(`All required tables are exists: ${tables.join(', ')}`)
61
+ if (tables.length) {
62
+ log.info(`All required tables are exists: ${tables.join(', ')}`)
63
+ }
64
+ } finally {
65
+ await db.destroy()
57
66
  }
58
67
  }