@saltcorn/postgres 0.8.5-beta.2 → 0.8.5-beta.4
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 +2 -2
- package/postgres.js +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/postgres",
|
|
3
|
-
"version": "0.8.5-beta.
|
|
3
|
+
"version": "0.8.5-beta.4",
|
|
4
4
|
"description": "Postgres structures for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@saltcorn/db-common": "0.8.5-beta.
|
|
15
|
+
"@saltcorn/db-common": "0.8.5-beta.4",
|
|
16
16
|
"pg": "^8.2.1",
|
|
17
17
|
"pg-copy-streams": "^5.1.1"
|
|
18
18
|
},
|
package/postgres.js
CHANGED
|
@@ -330,6 +330,39 @@ const drop_unique_constraint = async (table_name, field_names) => {
|
|
|
330
330
|
sql_log(sql);
|
|
331
331
|
await pool.query(sql);
|
|
332
332
|
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Add index
|
|
336
|
+
* @param {string} table_name - table name
|
|
337
|
+
* @param {string} field_name - list of columns (members of constraint)
|
|
338
|
+
* @returns {Promise<void>} no result
|
|
339
|
+
*/
|
|
340
|
+
const add_index = async (table_name, field_name) => {
|
|
341
|
+
// TBD check that there are no problems with lenght of constraint name
|
|
342
|
+
const sql = `create index "${sqlsanitize(table_name)}_${sqlsanitize(
|
|
343
|
+
field_name
|
|
344
|
+
)}_index" on "${getTenantSchema()}"."${sqlsanitize(
|
|
345
|
+
table_name
|
|
346
|
+
)}" ("${sqlsanitize(field_name)}");`;
|
|
347
|
+
sql_log(sql);
|
|
348
|
+
await pool.query(sql);
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Add index
|
|
353
|
+
* @param {string} table_name - table name
|
|
354
|
+
* @param {string} field_name - list of columns (members of constraint)
|
|
355
|
+
* @returns {Promise<void>} no result
|
|
356
|
+
*/
|
|
357
|
+
const drop_index = async (table_name, field_name) => {
|
|
358
|
+
// TBD check that there are no problems with lenght of constraint name
|
|
359
|
+
const sql = `drop index "${sqlsanitize(table_name)}_${sqlsanitize(
|
|
360
|
+
field_name
|
|
361
|
+
)}_index";`;
|
|
362
|
+
sql_log(sql);
|
|
363
|
+
await pool.query(sql);
|
|
364
|
+
};
|
|
365
|
+
|
|
333
366
|
/**
|
|
334
367
|
* Copy data from CSV to table?
|
|
335
368
|
* Only for PG
|
|
@@ -451,6 +484,8 @@ const postgresExports = {
|
|
|
451
484
|
drop_reset_schema,
|
|
452
485
|
add_unique_constraint,
|
|
453
486
|
drop_unique_constraint,
|
|
487
|
+
add_index,
|
|
488
|
+
drop_index,
|
|
454
489
|
reset_sequence,
|
|
455
490
|
getVersion,
|
|
456
491
|
copyFrom,
|