pgpm 4.32.2 → 4.34.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.
@@ -16,9 +16,13 @@ Admin Users Bootstrap Command:
16
16
  Options:
17
17
  --help, -h Show this help message
18
18
  --cwd <directory> Working directory (default: current directory)
19
+ --client Also create the restricted authenticated_client role
20
+ (for SQL-level proxy clients: inherits from
21
+ authenticated; server-enforced statement_timeout)
19
22
 
20
23
  Examples:
21
24
  pgpm admin-users bootstrap # Initialize postgres roles
25
+ pgpm admin-users bootstrap --client # Also create authenticated_client
22
26
  `;
23
27
  exports.default = async (argv, prompter, _options) => {
24
28
  // Show usage if explicitly requested
@@ -44,6 +48,9 @@ exports.default = async (argv, prompter, _options) => {
44
48
  const init = new core_1.PgpmInit(pgEnv);
45
49
  try {
46
50
  await init.bootstrapRoles(db.roles);
51
+ if (argv.client) {
52
+ await init.bootstrapClientRole(db.roles);
53
+ }
47
54
  log.success('postgres roles and permissions initialized successfully.');
48
55
  }
49
56
  finally {
@@ -0,0 +1,3 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
3
+ export default _default;
@@ -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,
@@ -14,9 +14,13 @@ Admin Users Bootstrap Command:
14
14
  Options:
15
15
  --help, -h Show this help message
16
16
  --cwd <directory> Working directory (default: current directory)
17
+ --client Also create the restricted authenticated_client role
18
+ (for SQL-level proxy clients: inherits from
19
+ authenticated; server-enforced statement_timeout)
17
20
 
18
21
  Examples:
19
22
  pgpm admin-users bootstrap # Initialize postgres roles
23
+ pgpm admin-users bootstrap --client # Also create authenticated_client
20
24
  `;
21
25
  export default async (argv, prompter, _options) => {
22
26
  // Show usage if explicitly requested
@@ -42,6 +46,9 @@ export default async (argv, prompter, _options) => {
42
46
  const init = new PgpmInit(pgEnv);
43
47
  try {
44
48
  await init.bootstrapRoles(db.roles);
49
+ if (argv.client) {
50
+ await init.bootstrapClientRole(db.roles);
51
+ }
45
52
  log.success('postgres roles and permissions initialized successfully.');
46
53
  }
47
54
  finally {
@@ -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,
@@ -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.32.2",
3
+ "version": "4.34.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",
@@ -46,18 +46,18 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@inquirerer/utils": "^3.3.9",
49
- "@pgpmjs/core": "^6.26.1",
50
- "@pgpmjs/env": "^2.26.0",
51
- "@pgpmjs/export": "^0.26.2",
49
+ "@pgpmjs/core": "^6.27.0",
50
+ "@pgpmjs/env": "^2.26.1",
51
+ "@pgpmjs/export": "^0.26.3",
52
52
  "@pgpmjs/logger": "^2.13.0",
53
- "@pgpmjs/types": "^2.30.0",
53
+ "@pgpmjs/types": "^2.31.0",
54
54
  "@pgsql/quotes": "^17.1.0",
55
55
  "appstash": "^0.7.0",
56
56
  "find-and-require-package-json": "^0.9.1",
57
57
  "genomic": "^5.6.2",
58
58
  "inquirerer": "^4.9.1",
59
59
  "js-yaml": "^4.1.0",
60
- "pg-cache": "^3.13.0",
60
+ "pg-cache": "^3.13.1",
61
61
  "pg-env": "^1.17.0",
62
62
  "pgsql-deparser": "^17.18.3",
63
63
  "semver": "^7.8.1",
@@ -76,5 +76,5 @@
76
76
  "pg",
77
77
  "pgsql"
78
78
  ],
79
- "gitHead": "ed31ed2aa63fcd2d42acec6f27e672dd300a3959"
79
+ "gitHead": "5a7e92e9849aa715367a33fa78a23c5f9adaefa0"
80
80
  }
@@ -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