From 70530a8ad2dc064baa9668f623e3196caacfdc64 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 14 Dec 2023 11:35:52 -0500 Subject: [PATCH] Optimizing sql format check. (#4268) * Optimizing sql format check. * Fixing format testing. * Fixing format testing 2. --- scripts/sql_format_check.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/sql_format_check.sh b/scripts/sql_format_check.sh index 0178204de..a75425da8 100755 --- a/scripts/sql_format_check.sh +++ b/scripts/sql_format_check.sh @@ -7,9 +7,12 @@ CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" cd $CWD/../ -find migrations -type f -name "*.sql" -print0 | while read -d $'\0' FILE -do - TMP_FILE="/tmp/tmp_pg_format.sql" - pg_format $FILE > $TMP_FILE - diff -u $FILE $TMP_FILE -done +# Copy the files to a temp dir +TMP_DIR=$(mktemp -d) +cp -a migrations/. $TMP_DIR + +# Format the new files +find $TMP_DIR -type f -name '*.sql' -exec pg_format -i {} + + +# Diff the directories +diff -r migrations $TMP_DIR