pgpm 2.10.0 → 2.10.2
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/README.md +22 -0
- package/commands/dump.d.ts +4 -0
- package/commands/dump.js +166 -0
- package/commands.js +2 -0
- package/esm/commands/dump.js +161 -0
- package/esm/commands.js +2 -0
- package/esm/index.js +1 -0
- package/esm/utils/display.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +10 -9
- package/utils/display.d.ts +1 -1
- package/utils/display.js +1 -0
package/README.md
CHANGED
|
@@ -328,6 +328,28 @@ pgpm package --no-plan
|
|
|
328
328
|
|
|
329
329
|
### Utilities
|
|
330
330
|
|
|
331
|
+
#### `pgpm dump`
|
|
332
|
+
|
|
333
|
+
Dump a postgres database to a sql file.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# dump to default timestamped file
|
|
337
|
+
pgpm dump --database mydb
|
|
338
|
+
|
|
339
|
+
# interactive mode (prompts for database)
|
|
340
|
+
pgpm dump
|
|
341
|
+
|
|
342
|
+
# dump to specific file
|
|
343
|
+
pgpm dump --database mydb --out ./backup.sql
|
|
344
|
+
|
|
345
|
+
# dump from a specific working directory
|
|
346
|
+
pgpm dump --database mydb --cwd ./packages/my-module
|
|
347
|
+
|
|
348
|
+
# dump with pruning
|
|
349
|
+
# useful for creating test fixtures or development snapshots
|
|
350
|
+
pgpm dump --database mydb --database-id <uuid>
|
|
351
|
+
```
|
|
352
|
+
|
|
331
353
|
#### `pgpm export`
|
|
332
354
|
|
|
333
355
|
Export migrations from existing databases.
|
package/commands/dump.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const logger_1 = require("@pgpmjs/logger");
|
|
7
|
+
const pg_env_1 = require("pg-env");
|
|
8
|
+
const pg_cache_1 = require("pg-cache");
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const quote_utils_1 = require("pgsql-deparser/utils/quote-utils");
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
const log = new logger_1.Logger('dump');
|
|
15
|
+
const dumpUsageText = `
|
|
16
|
+
Dump Command:
|
|
17
|
+
|
|
18
|
+
pgpm dump [options]
|
|
19
|
+
|
|
20
|
+
Dump a postgres database to a sql file.
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
--help, -h Show this help message
|
|
24
|
+
--db, --database <name> Target postgres database name
|
|
25
|
+
--out <path> Output file path
|
|
26
|
+
--database-id <id> When set, the dump will include a prune step that keeps only this database_id after restore
|
|
27
|
+
--cwd <directory> Working directory (default: current directory)
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
pgpm dump
|
|
31
|
+
pgpm dump --database mydb
|
|
32
|
+
pgpm dump --database mydb --out ./mydb.sql
|
|
33
|
+
pgpm dump --database mydb --database-id 00000000-0000-0000-0000-000000000000
|
|
34
|
+
`;
|
|
35
|
+
function nowStamp() {
|
|
36
|
+
const d = new Date();
|
|
37
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
38
|
+
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
|
|
39
|
+
}
|
|
40
|
+
async function runPgDump(args, env) {
|
|
41
|
+
await new Promise((resolve, reject) => {
|
|
42
|
+
const child = (0, child_process_1.spawn)('pg_dump', args, {
|
|
43
|
+
env,
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
shell: false
|
|
46
|
+
});
|
|
47
|
+
child.on('error', (err) => {
|
|
48
|
+
if (err.code === 'ENOENT') {
|
|
49
|
+
log.error('pg_dump not found; ensure PostgreSQL client tools are installed and in PATH');
|
|
50
|
+
}
|
|
51
|
+
reject(err);
|
|
52
|
+
});
|
|
53
|
+
child.on('close', (code) => {
|
|
54
|
+
if (code === 0) {
|
|
55
|
+
resolve();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
reject(new Error(`pg_dump exited with code ${code ?? 1}`));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function resolveDatabaseId(dbname, databaseIdRaw) {
|
|
63
|
+
const pool = (0, pg_cache_1.getPgPool)((0, pg_env_1.getPgEnvOptions)({ database: dbname }));
|
|
64
|
+
const res = await pool.query(`select id, name from metaschema_public.database order by name`);
|
|
65
|
+
const byId = res.rows.find((r) => String(r.id) === databaseIdRaw);
|
|
66
|
+
if (byId)
|
|
67
|
+
return { id: String(byId.id), name: String(byId.name) };
|
|
68
|
+
const byName = res.rows.find((r) => String(r.name) === databaseIdRaw);
|
|
69
|
+
if (byName)
|
|
70
|
+
return { id: String(byName.id), name: String(byName.name) };
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
async function buildPruneSql(dbname, databaseId) {
|
|
74
|
+
const pool = (0, pg_cache_1.getPgPool)((0, pg_env_1.getPgEnvOptions)({ database: dbname }));
|
|
75
|
+
const tables = await pool.query(`
|
|
76
|
+
select c.table_schema, c.table_name
|
|
77
|
+
from information_schema.columns c
|
|
78
|
+
join information_schema.tables t
|
|
79
|
+
on t.table_schema = c.table_schema
|
|
80
|
+
and t.table_name = c.table_name
|
|
81
|
+
where c.column_name = 'database_id'
|
|
82
|
+
and t.table_type = 'BASE TABLE'
|
|
83
|
+
and c.table_schema not in ('pg_catalog', 'information_schema')
|
|
84
|
+
order by c.table_schema, c.table_name
|
|
85
|
+
`);
|
|
86
|
+
const lines = [];
|
|
87
|
+
lines.push('');
|
|
88
|
+
lines.push('-- pgpm dump prune');
|
|
89
|
+
lines.push('-- this section keeps only one database_id after restore');
|
|
90
|
+
lines.push('do $$ begin');
|
|
91
|
+
lines.push(` raise notice 'pruning data to database_id ${databaseId}';`);
|
|
92
|
+
lines.push('end $$;');
|
|
93
|
+
lines.push('set session_replication_role = replica;');
|
|
94
|
+
for (const row of tables.rows) {
|
|
95
|
+
const schema = String(row.table_schema);
|
|
96
|
+
const table = String(row.table_name);
|
|
97
|
+
// Use QuoteUtils for robust identifier quoting
|
|
98
|
+
const qualified = quote_utils_1.QuoteUtils.quoteQualifiedIdentifier(schema, table);
|
|
99
|
+
// Use formatEString to safely escape the UUID/string literal
|
|
100
|
+
const dbIdLiteral = quote_utils_1.QuoteUtils.formatEString(databaseId);
|
|
101
|
+
lines.push(`delete from ${qualified} where database_id <> ${dbIdLiteral};`);
|
|
102
|
+
}
|
|
103
|
+
// Handle metaschema_public.database deletion
|
|
104
|
+
const metaschemaDb = quote_utils_1.QuoteUtils.quoteQualifiedIdentifier('metaschema_public', 'database');
|
|
105
|
+
const dbIdLiteral = quote_utils_1.QuoteUtils.formatEString(databaseId);
|
|
106
|
+
lines.push(`delete from ${metaschemaDb} where id <> ${dbIdLiteral};`);
|
|
107
|
+
lines.push('set session_replication_role = origin;');
|
|
108
|
+
lines.push('do $$ begin');
|
|
109
|
+
lines.push(` raise notice 'prune done';`);
|
|
110
|
+
lines.push('end $$;');
|
|
111
|
+
lines.push('');
|
|
112
|
+
return lines.join('\n');
|
|
113
|
+
}
|
|
114
|
+
// Helper to retrieve argument from parsed argv or positional _ array
|
|
115
|
+
function getArg(argv, key) {
|
|
116
|
+
if (argv[key])
|
|
117
|
+
return argv[key];
|
|
118
|
+
const args = argv._ || [];
|
|
119
|
+
const idx = args.indexOf(`--${key}`);
|
|
120
|
+
if (idx > -1 && args.length > idx + 1) {
|
|
121
|
+
return args[idx + 1];
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
exports.default = async (argv, prompter, _options) => {
|
|
126
|
+
if (argv.help || argv.h) {
|
|
127
|
+
console.log(dumpUsageText);
|
|
128
|
+
process.exit(0);
|
|
129
|
+
}
|
|
130
|
+
const cwd = argv.cwd || process.cwd();
|
|
131
|
+
const dbname = await (0, utils_1.getTargetDatabase)(argv, prompter, { message: 'Select database' });
|
|
132
|
+
const outPath = path_1.default.resolve(cwd, argv.out || `pgpm-dump-${dbname}-${nowStamp()}.sql`);
|
|
133
|
+
fs_1.default.mkdirSync(path_1.default.dirname(outPath), { recursive: true });
|
|
134
|
+
let databaseIdInfo = null;
|
|
135
|
+
const databaseIdRaw = getArg(argv, 'database-id');
|
|
136
|
+
if (databaseIdRaw) {
|
|
137
|
+
databaseIdInfo = await resolveDatabaseId(dbname, databaseIdRaw);
|
|
138
|
+
if (!databaseIdInfo) {
|
|
139
|
+
throw new Error(`unknown database-id ${databaseIdRaw}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
log.info(`dumping database ${dbname}`);
|
|
143
|
+
log.info(`writing to ${outPath}`);
|
|
144
|
+
if (databaseIdInfo) {
|
|
145
|
+
log.info(`database id ${databaseIdInfo.id}`);
|
|
146
|
+
}
|
|
147
|
+
const pgEnv = (0, pg_env_1.getPgEnvOptions)({ database: dbname });
|
|
148
|
+
const spawnEnv = (0, pg_env_1.getSpawnEnvWithPg)(pgEnv);
|
|
149
|
+
const args = [
|
|
150
|
+
'--format=plain',
|
|
151
|
+
'--no-owner',
|
|
152
|
+
'--no-privileges',
|
|
153
|
+
'--file',
|
|
154
|
+
outPath,
|
|
155
|
+
dbname
|
|
156
|
+
];
|
|
157
|
+
await runPgDump(args, spawnEnv);
|
|
158
|
+
if (databaseIdInfo) {
|
|
159
|
+
const pruneSql = await buildPruneSql(dbname, databaseIdInfo.id);
|
|
160
|
+
// Use writeFileSync with 'a' flag for explicit append as requested
|
|
161
|
+
fs_1.default.writeFileSync(outPath, pruneSql, { encoding: 'utf8', flag: 'a' });
|
|
162
|
+
log.info('added prune section to dump file');
|
|
163
|
+
}
|
|
164
|
+
log.success('dump complete');
|
|
165
|
+
return argv;
|
|
166
|
+
};
|
package/commands.js
CHANGED
|
@@ -14,6 +14,7 @@ const cache_1 = __importDefault(require("./commands/cache"));
|
|
|
14
14
|
const clear_1 = __importDefault(require("./commands/clear"));
|
|
15
15
|
const deploy_1 = __importDefault(require("./commands/deploy"));
|
|
16
16
|
const docker_1 = __importDefault(require("./commands/docker"));
|
|
17
|
+
const dump_1 = __importDefault(require("./commands/dump"));
|
|
17
18
|
const env_1 = __importDefault(require("./commands/env"));
|
|
18
19
|
const export_1 = __importDefault(require("./commands/export"));
|
|
19
20
|
const extension_1 = __importDefault(require("./commands/extension"));
|
|
@@ -50,6 +51,7 @@ const createPgpmCommandMap = (skipPgTeardown = false) => {
|
|
|
50
51
|
clear: pgt(clear_1.default),
|
|
51
52
|
deploy: pgt(deploy_1.default),
|
|
52
53
|
docker: docker_1.default,
|
|
54
|
+
dump: pgt(dump_1.default),
|
|
53
55
|
env: env_1.default,
|
|
54
56
|
verify: pgt(verify_1.default),
|
|
55
57
|
revert: pgt(revert_1.default),
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Logger } from '@pgpmjs/logger';
|
|
2
|
+
import { getPgEnvOptions, getSpawnEnvWithPg } from 'pg-env';
|
|
3
|
+
import { getPgPool } from 'pg-cache';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { QuoteUtils } from 'pgsql-deparser/utils/quote-utils';
|
|
8
|
+
import { getTargetDatabase } from '../utils';
|
|
9
|
+
const log = new Logger('dump');
|
|
10
|
+
const dumpUsageText = `
|
|
11
|
+
Dump Command:
|
|
12
|
+
|
|
13
|
+
pgpm dump [options]
|
|
14
|
+
|
|
15
|
+
Dump a postgres database to a sql file.
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
--help, -h Show this help message
|
|
19
|
+
--db, --database <name> Target postgres database name
|
|
20
|
+
--out <path> Output file path
|
|
21
|
+
--database-id <id> When set, the dump will include a prune step that keeps only this database_id after restore
|
|
22
|
+
--cwd <directory> Working directory (default: current directory)
|
|
23
|
+
|
|
24
|
+
Examples:
|
|
25
|
+
pgpm dump
|
|
26
|
+
pgpm dump --database mydb
|
|
27
|
+
pgpm dump --database mydb --out ./mydb.sql
|
|
28
|
+
pgpm dump --database mydb --database-id 00000000-0000-0000-0000-000000000000
|
|
29
|
+
`;
|
|
30
|
+
function nowStamp() {
|
|
31
|
+
const d = new Date();
|
|
32
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
33
|
+
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
|
|
34
|
+
}
|
|
35
|
+
async function runPgDump(args, env) {
|
|
36
|
+
await new Promise((resolve, reject) => {
|
|
37
|
+
const child = spawn('pg_dump', args, {
|
|
38
|
+
env,
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
shell: false
|
|
41
|
+
});
|
|
42
|
+
child.on('error', (err) => {
|
|
43
|
+
if (err.code === 'ENOENT') {
|
|
44
|
+
log.error('pg_dump not found; ensure PostgreSQL client tools are installed and in PATH');
|
|
45
|
+
}
|
|
46
|
+
reject(err);
|
|
47
|
+
});
|
|
48
|
+
child.on('close', (code) => {
|
|
49
|
+
if (code === 0) {
|
|
50
|
+
resolve();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
reject(new Error(`pg_dump exited with code ${code ?? 1}`));
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function resolveDatabaseId(dbname, databaseIdRaw) {
|
|
58
|
+
const pool = getPgPool(getPgEnvOptions({ database: dbname }));
|
|
59
|
+
const res = await pool.query(`select id, name from metaschema_public.database order by name`);
|
|
60
|
+
const byId = res.rows.find((r) => String(r.id) === databaseIdRaw);
|
|
61
|
+
if (byId)
|
|
62
|
+
return { id: String(byId.id), name: String(byId.name) };
|
|
63
|
+
const byName = res.rows.find((r) => String(r.name) === databaseIdRaw);
|
|
64
|
+
if (byName)
|
|
65
|
+
return { id: String(byName.id), name: String(byName.name) };
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
async function buildPruneSql(dbname, databaseId) {
|
|
69
|
+
const pool = getPgPool(getPgEnvOptions({ database: dbname }));
|
|
70
|
+
const tables = await pool.query(`
|
|
71
|
+
select c.table_schema, c.table_name
|
|
72
|
+
from information_schema.columns c
|
|
73
|
+
join information_schema.tables t
|
|
74
|
+
on t.table_schema = c.table_schema
|
|
75
|
+
and t.table_name = c.table_name
|
|
76
|
+
where c.column_name = 'database_id'
|
|
77
|
+
and t.table_type = 'BASE TABLE'
|
|
78
|
+
and c.table_schema not in ('pg_catalog', 'information_schema')
|
|
79
|
+
order by c.table_schema, c.table_name
|
|
80
|
+
`);
|
|
81
|
+
const lines = [];
|
|
82
|
+
lines.push('');
|
|
83
|
+
lines.push('-- pgpm dump prune');
|
|
84
|
+
lines.push('-- this section keeps only one database_id after restore');
|
|
85
|
+
lines.push('do $$ begin');
|
|
86
|
+
lines.push(` raise notice 'pruning data to database_id ${databaseId}';`);
|
|
87
|
+
lines.push('end $$;');
|
|
88
|
+
lines.push('set session_replication_role = replica;');
|
|
89
|
+
for (const row of tables.rows) {
|
|
90
|
+
const schema = String(row.table_schema);
|
|
91
|
+
const table = String(row.table_name);
|
|
92
|
+
// Use QuoteUtils for robust identifier quoting
|
|
93
|
+
const qualified = QuoteUtils.quoteQualifiedIdentifier(schema, table);
|
|
94
|
+
// Use formatEString to safely escape the UUID/string literal
|
|
95
|
+
const dbIdLiteral = QuoteUtils.formatEString(databaseId);
|
|
96
|
+
lines.push(`delete from ${qualified} where database_id <> ${dbIdLiteral};`);
|
|
97
|
+
}
|
|
98
|
+
// Handle metaschema_public.database deletion
|
|
99
|
+
const metaschemaDb = QuoteUtils.quoteQualifiedIdentifier('metaschema_public', 'database');
|
|
100
|
+
const dbIdLiteral = QuoteUtils.formatEString(databaseId);
|
|
101
|
+
lines.push(`delete from ${metaschemaDb} where id <> ${dbIdLiteral};`);
|
|
102
|
+
lines.push('set session_replication_role = origin;');
|
|
103
|
+
lines.push('do $$ begin');
|
|
104
|
+
lines.push(` raise notice 'prune done';`);
|
|
105
|
+
lines.push('end $$;');
|
|
106
|
+
lines.push('');
|
|
107
|
+
return lines.join('\n');
|
|
108
|
+
}
|
|
109
|
+
// Helper to retrieve argument from parsed argv or positional _ array
|
|
110
|
+
function getArg(argv, key) {
|
|
111
|
+
if (argv[key])
|
|
112
|
+
return argv[key];
|
|
113
|
+
const args = argv._ || [];
|
|
114
|
+
const idx = args.indexOf(`--${key}`);
|
|
115
|
+
if (idx > -1 && args.length > idx + 1) {
|
|
116
|
+
return args[idx + 1];
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
export default async (argv, prompter, _options) => {
|
|
121
|
+
if (argv.help || argv.h) {
|
|
122
|
+
console.log(dumpUsageText);
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
const cwd = argv.cwd || process.cwd();
|
|
126
|
+
const dbname = await getTargetDatabase(argv, prompter, { message: 'Select database' });
|
|
127
|
+
const outPath = path.resolve(cwd, argv.out || `pgpm-dump-${dbname}-${nowStamp()}.sql`);
|
|
128
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
129
|
+
let databaseIdInfo = null;
|
|
130
|
+
const databaseIdRaw = getArg(argv, 'database-id');
|
|
131
|
+
if (databaseIdRaw) {
|
|
132
|
+
databaseIdInfo = await resolveDatabaseId(dbname, databaseIdRaw);
|
|
133
|
+
if (!databaseIdInfo) {
|
|
134
|
+
throw new Error(`unknown database-id ${databaseIdRaw}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
log.info(`dumping database ${dbname}`);
|
|
138
|
+
log.info(`writing to ${outPath}`);
|
|
139
|
+
if (databaseIdInfo) {
|
|
140
|
+
log.info(`database id ${databaseIdInfo.id}`);
|
|
141
|
+
}
|
|
142
|
+
const pgEnv = getPgEnvOptions({ database: dbname });
|
|
143
|
+
const spawnEnv = getSpawnEnvWithPg(pgEnv);
|
|
144
|
+
const args = [
|
|
145
|
+
'--format=plain',
|
|
146
|
+
'--no-owner',
|
|
147
|
+
'--no-privileges',
|
|
148
|
+
'--file',
|
|
149
|
+
outPath,
|
|
150
|
+
dbname
|
|
151
|
+
];
|
|
152
|
+
await runPgDump(args, spawnEnv);
|
|
153
|
+
if (databaseIdInfo) {
|
|
154
|
+
const pruneSql = await buildPruneSql(dbname, databaseIdInfo.id);
|
|
155
|
+
// Use writeFileSync with 'a' flag for explicit append as requested
|
|
156
|
+
fs.writeFileSync(outPath, pruneSql, { encoding: 'utf8', flag: 'a' });
|
|
157
|
+
log.info('added prune section to dump file');
|
|
158
|
+
}
|
|
159
|
+
log.success('dump complete');
|
|
160
|
+
return argv;
|
|
161
|
+
};
|
package/esm/commands.js
CHANGED
|
@@ -8,6 +8,7 @@ import cache from './commands/cache';
|
|
|
8
8
|
import clear from './commands/clear';
|
|
9
9
|
import deploy from './commands/deploy';
|
|
10
10
|
import docker from './commands/docker';
|
|
11
|
+
import dump from './commands/dump';
|
|
11
12
|
import env from './commands/env';
|
|
12
13
|
import _export from './commands/export';
|
|
13
14
|
import extension from './commands/extension';
|
|
@@ -44,6 +45,7 @@ export const createPgpmCommandMap = (skipPgTeardown = false) => {
|
|
|
44
45
|
clear: pgt(clear),
|
|
45
46
|
deploy: pgt(deploy),
|
|
46
47
|
docker,
|
|
48
|
+
dump: pgt(dump),
|
|
47
49
|
env,
|
|
48
50
|
verify: pgt(verify),
|
|
49
51
|
revert: pgt(revert),
|
package/esm/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as analyze } from './commands/analyze';
|
|
|
10
10
|
export { default as clear } from './commands/clear';
|
|
11
11
|
export { default as deploy } from './commands/deploy';
|
|
12
12
|
export { default as docker } from './commands/docker';
|
|
13
|
+
export { default as dump } from './commands/dump';
|
|
13
14
|
export { default as env } from './commands/env';
|
|
14
15
|
export { default as _export } from './commands/export';
|
|
15
16
|
export { default as extension } from './commands/extension';
|
package/esm/utils/display.js
CHANGED
|
@@ -18,6 +18,7 @@ export const usageText = `
|
|
|
18
18
|
upgrade Upgrade installed pgpm modules to latest versions (alias: up)
|
|
19
19
|
|
|
20
20
|
Database Administration:
|
|
21
|
+
dump Dump a database to a sql file
|
|
21
22
|
kill Terminate database connections and optionally drop databases
|
|
22
23
|
install Install database modules
|
|
23
24
|
tag Add tags to changes for versioning
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { default as analyze } from './commands/analyze';
|
|
|
9
9
|
export { default as clear } from './commands/clear';
|
|
10
10
|
export { default as deploy } from './commands/deploy';
|
|
11
11
|
export { default as docker } from './commands/docker';
|
|
12
|
+
export { default as dump } from './commands/dump';
|
|
12
13
|
export { default as env } from './commands/env';
|
|
13
14
|
export { default as _export } from './commands/export';
|
|
14
15
|
export { default as extension } from './commands/extension';
|
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.options = exports.verify = exports.testPackages = exports.tag = exports.revert = exports.renameCmd = exports.remove = exports.plan = exports._package = exports.migrate = exports.kill = exports.install = exports.extension = exports._export = exports.env = exports.docker = exports.deploy = exports.clear = exports.analyze = exports.adminUsers = exports.add = exports.createPgpmCommandMap = exports.createInitUsageText = void 0;
|
|
21
|
+
exports.options = exports.verify = exports.testPackages = exports.tag = exports.revert = exports.renameCmd = exports.remove = exports.plan = exports._package = exports.migrate = exports.kill = exports.install = exports.extension = exports._export = exports.env = exports.dump = exports.docker = exports.deploy = exports.clear = exports.analyze = exports.adminUsers = exports.add = exports.createPgpmCommandMap = exports.createInitUsageText = void 0;
|
|
22
22
|
const find_and_require_package_json_1 = require("find-and-require-package-json");
|
|
23
23
|
const inquirerer_1 = require("inquirerer");
|
|
24
24
|
const commands_1 = require("./commands");
|
|
@@ -37,6 +37,8 @@ var deploy_1 = require("./commands/deploy");
|
|
|
37
37
|
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return __importDefault(deploy_1).default; } });
|
|
38
38
|
var docker_1 = require("./commands/docker");
|
|
39
39
|
Object.defineProperty(exports, "docker", { enumerable: true, get: function () { return __importDefault(docker_1).default; } });
|
|
40
|
+
var dump_1 = require("./commands/dump");
|
|
41
|
+
Object.defineProperty(exports, "dump", { enumerable: true, get: function () { return __importDefault(dump_1).default; } });
|
|
40
42
|
var env_1 = require("./commands/env");
|
|
41
43
|
Object.defineProperty(exports, "env", { enumerable: true, get: function () { return __importDefault(env_1).default; } });
|
|
42
44
|
var export_1 = require("./commands/export");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgpm",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostgreSQL Package Manager - Database migration and package management CLI",
|
|
6
6
|
"main": "index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:watch": "jest --watch"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@inquirerer/test": "^1.2.
|
|
36
|
+
"@inquirerer/test": "^1.2.5",
|
|
37
37
|
"@types/js-yaml": "^4.0.9",
|
|
38
38
|
"@types/minimist": "^1.2.5",
|
|
39
39
|
"@types/node": "^20.12.7",
|
|
@@ -46,19 +46,20 @@
|
|
|
46
46
|
"ts-node": "^10.9.2"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@inquirerer/utils": "^3.1.
|
|
50
|
-
"@pgpmjs/core": "^4.
|
|
49
|
+
"@inquirerer/utils": "^3.1.3",
|
|
50
|
+
"@pgpmjs/core": "^4.11.0",
|
|
51
51
|
"@pgpmjs/env": "^2.9.3",
|
|
52
52
|
"@pgpmjs/logger": "^1.3.7",
|
|
53
53
|
"@pgpmjs/types": "^2.14.0",
|
|
54
|
-
"appstash": "^0.2.
|
|
55
|
-
"find-and-require-package-json": "^0.8.
|
|
56
|
-
"genomic": "^5.2.
|
|
57
|
-
"inquirerer": "^4.
|
|
54
|
+
"appstash": "^0.2.8",
|
|
55
|
+
"find-and-require-package-json": "^0.8.6",
|
|
56
|
+
"genomic": "^5.2.3",
|
|
57
|
+
"inquirerer": "^4.3.1",
|
|
58
58
|
"js-yaml": "^4.1.0",
|
|
59
59
|
"minimist": "^1.2.8",
|
|
60
60
|
"pg-cache": "^1.6.14",
|
|
61
61
|
"pg-env": "^1.2.5",
|
|
62
|
+
"pgsql-deparser": "^17.17.2",
|
|
62
63
|
"semver": "^7.6.2",
|
|
63
64
|
"shelljs": "^0.10.0",
|
|
64
65
|
"yanse": "^0.1.11"
|
|
@@ -75,5 +76,5 @@
|
|
|
75
76
|
"pg",
|
|
76
77
|
"pgsql"
|
|
77
78
|
],
|
|
78
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "7c9b2f2b7a2a56a941aafe62cc7f2b4a90afa1bc"
|
|
79
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 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 PostgreSQL Docker containers (start/stop)\n env Manage PostgreSQL environment variables\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\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 PostgreSQL Docker containers (start/stop)\n env Manage PostgreSQL environment variables\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
|
@@ -21,6 +21,7 @@ exports.usageText = `
|
|
|
21
21
|
upgrade Upgrade installed pgpm modules to latest versions (alias: up)
|
|
22
22
|
|
|
23
23
|
Database Administration:
|
|
24
|
+
dump Dump a database to a sql file
|
|
24
25
|
kill Terminate database connections and optionally drop databases
|
|
25
26
|
install Install database modules
|
|
26
27
|
tag Add tags to changes for versioning
|