Files
lemmy/scripts/sql_format_check.sh
Nutomic 896e8f1896 Parallel sql format (#5773)
* Parallel sql format

* change image

* -q

* unformatted

* Revert "unformatted"

This reverts commit 22e79fe4c5.

* -q
2025-06-11 16:35:41 -04:00

21 lines
555 B
Bash
Executable File

#!/usr/bin/env bash
set -e
# This check is only used for CI.
CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
cd "$CWD/../"
# Copy the files to a temp dir
TMP_DIR=$(mktemp -d)
cp -a migrations/. $TMP_DIR/migrations
cp -a crates/db_schema_file/replaceable_schema/. $TMP_DIR/replaceable_schema
# Format the new files
find $TMP_DIR -type f -name '*.sql' -print0 | xargs -0 -P 10 -L 10 pg_format -i
# Diff the directories
diff -r migrations $TMP_DIR/migrations
diff -r crates/db_schema_file/replaceable_schema $TMP_DIR/replaceable_schema