@catladder/cli 0.0.0-main-66eb6f83 → 0.0.0-main-2641fe28
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.
|
@@ -2972,15 +2972,18 @@ const spawnCopyDb = async (opts) => {
|
|
|
2972
2972
|
exports.spawnCopyDb = spawnCopyDb;
|
|
2973
2973
|
const createCopyDbScript = ({ targetPassword, targetPort, targetUsername, sourceUsername, sourcePassword, sourcePort, sourceDbName, targetDbName, }) => {
|
|
2974
2974
|
const targetPSQL = (command) => `PGPASSWORD=${targetPassword} psql -p ${targetPort} --host=localhost --user=${targetUsername} -q ${command}`;
|
|
2975
|
+
// URL-encode credentials to handle special characters like @, :, /, etc.
|
|
2976
|
+
const encodedSourceUsername = encodeURIComponent(sourceUsername);
|
|
2977
|
+
const encodedSourcePassword = encodeURIComponent(sourcePassword);
|
|
2975
2978
|
const copyDBScript = `
|
|
2976
2979
|
set -e
|
|
2977
|
-
|
|
2978
|
-
|
|
2980
|
+
|
|
2981
|
+
|
|
2979
2982
|
|
|
2980
2983
|
dumptmp=$(mktemp /tmp/dump.XXXXXX)
|
|
2981
2984
|
|
|
2982
2985
|
echo "Dumping file to $dumptmp"
|
|
2983
|
-
pg_dump --dbname=postgres://${
|
|
2986
|
+
pg_dump --dbname=postgres://${encodedSourceUsername}:${encodedSourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges > $dumptmp
|
|
2984
2987
|
echo "dump done"
|
|
2985
2988
|
${targetPSQL(`-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`)}
|
|
2986
2989
|
${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
|
|
@@ -12,15 +12,18 @@ const spawnCopyDb = async (opts) => {
|
|
|
12
12
|
exports.spawnCopyDb = spawnCopyDb;
|
|
13
13
|
const createCopyDbScript = ({ targetPassword, targetPort, targetUsername, sourceUsername, sourcePassword, sourcePort, sourceDbName, targetDbName, }) => {
|
|
14
14
|
const targetPSQL = (command) => `PGPASSWORD=${targetPassword} psql -p ${targetPort} --host=localhost --user=${targetUsername} -q ${command}`;
|
|
15
|
+
// URL-encode credentials to handle special characters like @, :, /, etc.
|
|
16
|
+
const encodedSourceUsername = encodeURIComponent(sourceUsername);
|
|
17
|
+
const encodedSourcePassword = encodeURIComponent(sourcePassword);
|
|
15
18
|
const copyDBScript = `
|
|
16
19
|
set -e
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
dumptmp=$(mktemp /tmp/dump.XXXXXX)
|
|
21
24
|
|
|
22
25
|
echo "Dumping file to $dumptmp"
|
|
23
|
-
pg_dump --dbname=postgres://${
|
|
26
|
+
pg_dump --dbname=postgres://${encodedSourceUsername}:${encodedSourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges > $dumptmp
|
|
24
27
|
echo "dump done"
|
|
25
28
|
${targetPSQL(`-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`)}
|
|
26
29
|
${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyDb.js","sourceRoot":"","sources":["../../../../../src/gcloud/cloudSql/copyDb.ts"],"names":[],"mappings":";;;AAAA,iEAA8C;AAWvC,MAAM,WAAW,GAAG,KAAK,EAAE,IAAU,EAAE,EAAE;IAC9C,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAExC,OAAO,MAAM,IAAA,6BAAK,EAAC,MAAM,EAAE,EAAE,EAAE;QAC7B,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB;AACF,MAAM,kBAAkB,GAAG,CAAC,EAC1B,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,YAAY,EACZ,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