working version i guess
Build and Push Docker Images / build-and-push (push) Successful in 23s

This commit is contained in:
2025-05-21 21:14:17 +02:00
parent 2c9485b25d
commit 2d9f236798
2 changed files with 30 additions and 17 deletions
+6 -12
View File
@@ -1,17 +1,11 @@
#!/bin/bash
set -e
# Create the target database if it doesn't exist
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
DO
\$do\$
BEGIN
IF NOT EXISTS (SELECT FROM pg_database WHERE datname = '$TARGET_DB_NAME') THEN
CREATE DATABASE $TARGET_DB_NAME OWNER $POSTGRES_USER;
END IF;
END
\$do\$;
EOSQL
# Check if database exists
if ! psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -tAc "SELECT 1 FROM pg_database WHERE datname = '$TARGET_DB_NAME'" | grep -q 1; then
# Create the target database if it doesn't exist
createdb -U "$POSTGRES_USER" -O "$POSTGRES_USER" "$TARGET_DB_NAME"
fi
# Enable the pgvector extension on both databases
for DB in "$POSTGRES_DB" "$TARGET_DB_NAME"; do
@@ -28,4 +22,4 @@ else
echo "No SOURCE_DB_URL provided, skipping initial refresh"
fi
echo "Database initialization completed at $(date)"
echo "Database initialization completed at $(date)"