pgpm 4.32.1 → 4.33.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/commands/tune.d.ts +3 -0
- package/commands/tune.js +80 -0
- package/commands.js +2 -0
- package/esm/commands/tune.js +78 -0
- package/esm/commands.js +2 -0
- package/esm/utils/display.js +1 -0
- package/package.json +3 -3
- package/utils/display.d.ts +1 -1
- package/utils/display.js +1 -0
package/commands/tune.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("@pgpmjs/logger");
|
|
4
|
+
const pg_cache_1 = require("pg-cache");
|
|
5
|
+
const log = new logger_1.Logger('tune');
|
|
6
|
+
const tuneUsageText = `
|
|
7
|
+
Tune Command:
|
|
8
|
+
|
|
9
|
+
pgpm tune [OPTIONS]
|
|
10
|
+
|
|
11
|
+
Tune PostgreSQL for throwaway environments (CI, local dev, test containers).
|
|
12
|
+
Disables durability guarantees to eliminate checkpoint/fsync I/O stalls,
|
|
13
|
+
which can make DDL-heavy workloads (e.g. provisioning) dramatically faster
|
|
14
|
+
and more reliable on slow disks.
|
|
15
|
+
|
|
16
|
+
Applies via ALTER SYSTEM + pg_reload_conf() (no restart required):
|
|
17
|
+
|
|
18
|
+
fsync = off
|
|
19
|
+
synchronous_commit = off
|
|
20
|
+
full_page_writes = off
|
|
21
|
+
checkpoint_timeout = 30min
|
|
22
|
+
max_wal_size = 8GB
|
|
23
|
+
|
|
24
|
+
WARNING: These settings can cause data loss or corruption on crash.
|
|
25
|
+
Only use against disposable databases — never production.
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--help, -h Show this help message
|
|
29
|
+
--yes Skip confirmation prompt
|
|
30
|
+
--reset Restore all settings above to server defaults
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
pgpm tune --yes Tune a CI/test database (non-interactive)
|
|
34
|
+
pgpm tune --reset --yes Restore default durability settings
|
|
35
|
+
`;
|
|
36
|
+
const TUNE_SETTINGS = {
|
|
37
|
+
fsync: 'off',
|
|
38
|
+
synchronous_commit: 'off',
|
|
39
|
+
full_page_writes: 'off',
|
|
40
|
+
checkpoint_timeout: '30min',
|
|
41
|
+
max_wal_size: '8GB'
|
|
42
|
+
};
|
|
43
|
+
exports.default = async (argv, prompter, _options) => {
|
|
44
|
+
if (argv.help || argv.h) {
|
|
45
|
+
console.log(tuneUsageText);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
const reset = argv.reset === true;
|
|
49
|
+
const { yes } = await prompter.prompt(argv, [
|
|
50
|
+
{
|
|
51
|
+
type: 'confirm',
|
|
52
|
+
name: 'yes',
|
|
53
|
+
message: reset
|
|
54
|
+
? 'Restore PostgreSQL durability settings to server defaults?'
|
|
55
|
+
: 'Disable PostgreSQL durability? This risks data loss on crash and must never be used in production.',
|
|
56
|
+
default: false
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
if (!yes) {
|
|
60
|
+
log.info('Operation cancelled.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const db = await (0, pg_cache_1.getPgPool)({
|
|
64
|
+
database: 'postgres'
|
|
65
|
+
});
|
|
66
|
+
for (const [setting, value] of Object.entries(TUNE_SETTINGS)) {
|
|
67
|
+
if (reset) {
|
|
68
|
+
await db.query(`ALTER SYSTEM RESET ${setting};`);
|
|
69
|
+
log.info(`reset ${setting}`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
await db.query(`ALTER SYSTEM SET ${setting} = '${value}';`);
|
|
73
|
+
log.info(`set ${setting} = ${value}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
await db.query('SELECT pg_reload_conf();');
|
|
77
|
+
log.success(reset
|
|
78
|
+
? 'PostgreSQL durability settings restored to defaults.'
|
|
79
|
+
: 'PostgreSQL tuned for throwaway environments (durability disabled).');
|
|
80
|
+
};
|
package/commands.js
CHANGED
|
@@ -32,6 +32,7 @@ const revert_1 = __importDefault(require("./commands/revert"));
|
|
|
32
32
|
const slice_1 = __importDefault(require("./commands/slice"));
|
|
33
33
|
const tag_1 = __importDefault(require("./commands/tag"));
|
|
34
34
|
const test_packages_1 = __importDefault(require("./commands/test-packages"));
|
|
35
|
+
const tune_1 = __importDefault(require("./commands/tune"));
|
|
35
36
|
const verify_1 = __importDefault(require("./commands/verify"));
|
|
36
37
|
const utils_2 = require("./utils");
|
|
37
38
|
const withPgTeardown = (fn, skipTeardown = false) => async (...args) => {
|
|
@@ -70,6 +71,7 @@ const createPgpmCommandMap = (skipPgTeardown = false) => {
|
|
|
70
71
|
rename: pgt(rename_1.default),
|
|
71
72
|
slice: slice_1.default,
|
|
72
73
|
'test-packages': pgt(test_packages_1.default),
|
|
74
|
+
tune: pgt(tune_1.default),
|
|
73
75
|
upgrade: pgt(upgrade_1.default),
|
|
74
76
|
up: pgt(upgrade_1.default),
|
|
75
77
|
cache: cache_1.default,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Logger } from '@pgpmjs/logger';
|
|
2
|
+
import { getPgPool } from 'pg-cache';
|
|
3
|
+
const log = new Logger('tune');
|
|
4
|
+
const tuneUsageText = `
|
|
5
|
+
Tune Command:
|
|
6
|
+
|
|
7
|
+
pgpm tune [OPTIONS]
|
|
8
|
+
|
|
9
|
+
Tune PostgreSQL for throwaway environments (CI, local dev, test containers).
|
|
10
|
+
Disables durability guarantees to eliminate checkpoint/fsync I/O stalls,
|
|
11
|
+
which can make DDL-heavy workloads (e.g. provisioning) dramatically faster
|
|
12
|
+
and more reliable on slow disks.
|
|
13
|
+
|
|
14
|
+
Applies via ALTER SYSTEM + pg_reload_conf() (no restart required):
|
|
15
|
+
|
|
16
|
+
fsync = off
|
|
17
|
+
synchronous_commit = off
|
|
18
|
+
full_page_writes = off
|
|
19
|
+
checkpoint_timeout = 30min
|
|
20
|
+
max_wal_size = 8GB
|
|
21
|
+
|
|
22
|
+
WARNING: These settings can cause data loss or corruption on crash.
|
|
23
|
+
Only use against disposable databases — never production.
|
|
24
|
+
|
|
25
|
+
Options:
|
|
26
|
+
--help, -h Show this help message
|
|
27
|
+
--yes Skip confirmation prompt
|
|
28
|
+
--reset Restore all settings above to server defaults
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
pgpm tune --yes Tune a CI/test database (non-interactive)
|
|
32
|
+
pgpm tune --reset --yes Restore default durability settings
|
|
33
|
+
`;
|
|
34
|
+
const TUNE_SETTINGS = {
|
|
35
|
+
fsync: 'off',
|
|
36
|
+
synchronous_commit: 'off',
|
|
37
|
+
full_page_writes: 'off',
|
|
38
|
+
checkpoint_timeout: '30min',
|
|
39
|
+
max_wal_size: '8GB'
|
|
40
|
+
};
|
|
41
|
+
export default async (argv, prompter, _options) => {
|
|
42
|
+
if (argv.help || argv.h) {
|
|
43
|
+
console.log(tuneUsageText);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
const reset = argv.reset === true;
|
|
47
|
+
const { yes } = await prompter.prompt(argv, [
|
|
48
|
+
{
|
|
49
|
+
type: 'confirm',
|
|
50
|
+
name: 'yes',
|
|
51
|
+
message: reset
|
|
52
|
+
? 'Restore PostgreSQL durability settings to server defaults?'
|
|
53
|
+
: 'Disable PostgreSQL durability? This risks data loss on crash and must never be used in production.',
|
|
54
|
+
default: false
|
|
55
|
+
}
|
|
56
|
+
]);
|
|
57
|
+
if (!yes) {
|
|
58
|
+
log.info('Operation cancelled.');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const db = await getPgPool({
|
|
62
|
+
database: 'postgres'
|
|
63
|
+
});
|
|
64
|
+
for (const [setting, value] of Object.entries(TUNE_SETTINGS)) {
|
|
65
|
+
if (reset) {
|
|
66
|
+
await db.query(`ALTER SYSTEM RESET ${setting};`);
|
|
67
|
+
log.info(`reset ${setting}`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
await db.query(`ALTER SYSTEM SET ${setting} = '${value}';`);
|
|
71
|
+
log.info(`set ${setting} = ${value}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
await db.query('SELECT pg_reload_conf();');
|
|
75
|
+
log.success(reset
|
|
76
|
+
? 'PostgreSQL durability settings restored to defaults.'
|
|
77
|
+
: 'PostgreSQL tuned for throwaway environments (durability disabled).');
|
|
78
|
+
};
|
package/esm/commands.js
CHANGED
|
@@ -26,6 +26,7 @@ import revert from './commands/revert';
|
|
|
26
26
|
import slice from './commands/slice';
|
|
27
27
|
import tag from './commands/tag';
|
|
28
28
|
import testPackages from './commands/test-packages';
|
|
29
|
+
import tune from './commands/tune';
|
|
29
30
|
import verify from './commands/verify';
|
|
30
31
|
import { usageText } from './utils';
|
|
31
32
|
const withPgTeardown = (fn, skipTeardown = false) => async (...args) => {
|
|
@@ -64,6 +65,7 @@ export const createPgpmCommandMap = (skipPgTeardown = false) => {
|
|
|
64
65
|
rename: pgt(renameCmd),
|
|
65
66
|
slice,
|
|
66
67
|
'test-packages': pgt(testPackages),
|
|
68
|
+
tune: pgt(tune),
|
|
67
69
|
upgrade: pgt(upgrade),
|
|
68
70
|
up: pgt(upgrade),
|
|
69
71
|
cache,
|
package/esm/utils/display.js
CHANGED
|
@@ -27,6 +27,7 @@ export const usageText = `
|
|
|
27
27
|
analyze Analyze database structure
|
|
28
28
|
rename Rename database changes
|
|
29
29
|
admin-users Manage admin users
|
|
30
|
+
tune Tune PostgreSQL for throwaway environments (CI/test)
|
|
30
31
|
|
|
31
32
|
Testing:
|
|
32
33
|
test-packages Run integration tests on all workspace packages
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgpm",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.33.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostgreSQL Package Manager - Database migration and package management CLI",
|
|
6
6
|
"main": "index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@inquirerer/utils": "^3.3.9",
|
|
49
49
|
"@pgpmjs/core": "^6.26.1",
|
|
50
50
|
"@pgpmjs/env": "^2.26.0",
|
|
51
|
-
"@pgpmjs/export": "^0.26.
|
|
51
|
+
"@pgpmjs/export": "^0.26.2",
|
|
52
52
|
"@pgpmjs/logger": "^2.13.0",
|
|
53
53
|
"@pgpmjs/types": "^2.30.0",
|
|
54
54
|
"@pgsql/quotes": "^17.1.0",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"pg",
|
|
77
77
|
"pgsql"
|
|
78
78
|
],
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "a782774ac3dbf1b1351e1ff4b6e0e8028a53e1c5"
|
|
80
80
|
}
|
package/utils/display.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const usageText = "\n Usage: pgpm <command> [options]\n\n Core Database Operations:\n add Add database changes to plans and create SQL files\n deploy Deploy database changes and migrations\n verify Verify database state and migrations\n revert Revert database changes and migrations\n\n Project Management:\n init Initialize workspace or module\n extension Manage module dependencies\n plan Generate module deployment plans\n package Package module for distribution\n export Export database migrations from existing databases\n update Update pgpm to the latest version\n cache Manage cached templates (clean)\n upgrade Upgrade installed pgpm modules to latest versions (alias: up)\n\n Database Administration:\n dump Dump a database to a sql file\n kill Terminate database connections and optionally drop databases\n install Install database modules\n tag Add tags to changes for versioning\n clear Clear database state\n remove Remove database changes\n analyze Analyze database structure\n rename Rename database changes\n admin-users Manage admin users\n\n Testing:\n test-packages Run integration tests on all workspace packages\n\n Migration Tools:\n migrate Migration management subcommands\n init Initialize migration tracking\n status Show migration status\n list List all changes\n deps Show change dependencies\n \n Development Tools:\n docker Manage Docker containers (start/stop/ls, --minio)\n env Manage environment variables (--supabase, --minio)\n test-packages Run integration tests on workspace packages\n \n Global Options:\n -h, --help Display this help information\n -v, --version Display version information\n --cwd <directory> Working directory (default: current directory)\n\n Individual Command Help:\n pgpm <command> --help Display detailed help for specific command\n pgpm <command> -h Display detailed help for specific command\n\n Examples:\n pgpm deploy --help Show deploy command options\n pgpm init workspace Initialize new workspace\n pgpm install @pgpm/base32 Install a database module\n ";
|
|
1
|
+
export declare const usageText = "\n Usage: pgpm <command> [options]\n\n Core Database Operations:\n add Add database changes to plans and create SQL files\n deploy Deploy database changes and migrations\n verify Verify database state and migrations\n revert Revert database changes and migrations\n\n Project Management:\n init Initialize workspace or module\n extension Manage module dependencies\n plan Generate module deployment plans\n package Package module for distribution\n export Export database migrations from existing databases\n update Update pgpm to the latest version\n cache Manage cached templates (clean)\n upgrade Upgrade installed pgpm modules to latest versions (alias: up)\n\n Database Administration:\n dump Dump a database to a sql file\n kill Terminate database connections and optionally drop databases\n install Install database modules\n tag Add tags to changes for versioning\n clear Clear database state\n remove Remove database changes\n analyze Analyze database structure\n rename Rename database changes\n admin-users Manage admin users\n tune Tune PostgreSQL for throwaway environments (CI/test)\n\n Testing:\n test-packages Run integration tests on all workspace packages\n\n Migration Tools:\n migrate Migration management subcommands\n init Initialize migration tracking\n status Show migration status\n list List all changes\n deps Show change dependencies\n \n Development Tools:\n docker Manage Docker containers (start/stop/ls, --minio)\n env Manage environment variables (--supabase, --minio)\n test-packages Run integration tests on workspace packages\n \n Global Options:\n -h, --help Display this help information\n -v, --version Display version information\n --cwd <directory> Working directory (default: current directory)\n\n Individual Command Help:\n pgpm <command> --help Display detailed help for specific command\n pgpm <command> -h Display detailed help for specific command\n\n Examples:\n pgpm deploy --help Show deploy command options\n pgpm init workspace Initialize new workspace\n pgpm install @pgpm/base32 Install a database module\n ";
|
package/utils/display.js
CHANGED
|
@@ -30,6 +30,7 @@ exports.usageText = `
|
|
|
30
30
|
analyze Analyze database structure
|
|
31
31
|
rename Rename database changes
|
|
32
32
|
admin-users Manage admin users
|
|
33
|
+
tune Tune PostgreSQL for throwaway environments (CI/test)
|
|
33
34
|
|
|
34
35
|
Testing:
|
|
35
36
|
test-packages Run integration tests on all workspace packages
|