You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lemmy/scripts/sql_format_check.sh

21 lines
523 B
Bash

#!/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/replaceable_schema/. $TMP_DIR/replaceable_schema
# Format the new files
find $TMP_DIR -type f -name '*.sql' -exec pg_format -i {} +
# Diff the directories
diff -r migrations $TMP_DIR/migrations
diff -r crates/db_schema/replaceable_schema $TMP_DIR/replaceable_schema