@catladder/cli 4.3.0 ā 4.4.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/dist/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +1 -1
- package/dist/cli/src/gcloud/cloudSql/copyDb.js +15 -13
- package/dist/cli/src/gcloud/cloudSql/copyDb.js.map +1 -1
- package/dist/pipeline/src/constants.js +1 -1
- package/dist/pipeline/src/pipeline/createMainPipeline.js +1 -1
- package/dist/pipeline/src/pipeline/createMainPipeline.js.map +1 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js +1 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js.map +1 -1
- package/dist/pipeline/src/rules/index.d.ts +2 -2
- package/dist/pipeline/src/rules/index.js +4 -4
- package/dist/pipeline/src/rules/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/gcloud/cloudSql/copyDb.ts +15 -13
package/package.json
CHANGED
|
@@ -37,24 +37,26 @@ const createCopyDbScript = ({
|
|
|
37
37
|
const copyDBScript = `
|
|
38
38
|
set -e
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
dumptmp=$(mktemp /tmp/dump.XXXXXX)
|
|
43
|
-
|
|
44
|
-
echo "Dumping file to $dumptmp"
|
|
45
|
-
pg_dump --dbname=postgres://${encodedSourceUsername}:${encodedSourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges > $dumptmp
|
|
46
|
-
echo "dump done"
|
|
47
40
|
${targetPSQL(
|
|
48
41
|
`-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`,
|
|
49
42
|
)}
|
|
50
43
|
${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
echo "Estimating database size..."
|
|
45
|
+
DB_SIZE=$(PGPASSWORD=${encodedSourcePassword} psql --dbname=postgres://${encodedSourceUsername}:${encodedSourcePassword}@localhost:${sourcePort}/${sourceDbName} -t -A -c "SELECT pg_database_size('${sourceDbName}')")
|
|
46
|
+
# pg_database_size includes indexes, TOAST, and free space ā pg_dump output is roughly 40% of that
|
|
47
|
+
ESTIMATED_DUMP_SIZE=$((DB_SIZE * 40 / 100))
|
|
48
|
+
echo "Estimated dump size: $((ESTIMATED_DUMP_SIZE / 1024 / 1024)) MB (~40% of $((DB_SIZE / 1024 / 1024)) MB database size)"
|
|
49
|
+
|
|
50
|
+
PROGRESS=""
|
|
51
|
+
if command -v pv &> /dev/null; then
|
|
52
|
+
PROGRESS="pv -s $ESTIMATED_DUMP_SIZE |"
|
|
53
|
+
else
|
|
54
|
+
echo "(install 'pv' for progress info)"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
echo "Dumping and restoring via pipe..."
|
|
58
|
+
eval "pg_dump --dbname=postgres://${encodedSourceUsername}:${encodedSourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges | $PROGRESS ${targetPSQL(`"${targetDbName}" 1> /dev/null`)}"
|
|
54
59
|
|
|
55
|
-
echo "Clean up..."
|
|
56
|
-
set +e
|
|
57
|
-
rm $dumptmp
|
|
58
60
|
echo "\nš± Done!"
|
|
59
61
|
`;
|
|
60
62
|
return copyDBScript;
|