init
Build and Push Docker Images / build-and-push (push) Successful in 1m17s

This commit is contained in:
2025-05-21 21:08:33 +02:00
parent 9fff5cef23
commit 2c9485b25d
+31
View File
@@ -0,0 +1,31 @@
#!/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
# Enable the pgvector extension on both databases
for DB in "$POSTGRES_DB" "$TARGET_DB_NAME"; do
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$DB" <<-EOSQL
CREATE EXTENSION IF NOT EXISTS vector;
EOSQL
done
# Run the initial refresh if SOURCE_DB_URL is provided
if [ ! -z "$SOURCE_DB_URL" ]; then
echo "Running initial database refresh..."
/usr/local/bin/refresh.sh
else
echo "No SOURCE_DB_URL provided, skipping initial refresh"
fi
echo "Database initialization completed at $(date)"