Skip to content

Commit bcb7c9f

Browse files
Update replace_sql_placeholders.sh
1 parent 2ffaec7 commit bcb7c9f

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

replace_sql_placeholders.sh

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
#!/bin/bash
2-
set +x
2+
set -x
33

44
# Step 0: Replace placeholders in the SQL file
5-
# Path to the original SQL file
6-
SQL_FILE="supabase/migrations/20240108234540_setup.sql"
7-
85
# Temporary file for storing the modified SQL file
96
TEMP_FILE="temp.sql"
107

8+
# Path to the original SQL file
9+
SQL_FILE="supabase/migrations/20240108234540_setup.sql"
10+
ls -l $SQL_FILE
11+
1112
# Environment variables (these should be set in your Railway environment or .env file)
1213
PROJECT_URL=${NEXT_PUBLIC_SUPABASE_URL:-http://localhost:8000}
1314
SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY:-your_default_service_role_key}
1415

15-
# Replace placeholders in the SQL file without logging sensitive information
16-
sed "s|PROJECT_URL_PLACEHOLDER|$PROJECT_URL|g; s|SERVICE_ROLE_KEY_PLACEHOLDER|$SERVICE_ROLE_KEY|g" $SQL_FILE > $TEMP_FILE > /dev/null 2>&1
16+
# Replace placeholders in the SQL file
17+
sed "s|PROJECT_URL_PLACEHOLDER|$PROJECT_URL|g; s|SERVICE_ROLE_KEY_PLACEHOLDER|$SERVICE_ROLE_KEY|g" $SQL_FILE > $TEMP_FILE
18+
19+
# Checking size of tempfile
20+
echo "Checking the temp file:"
21+
ls -l $TEMP_FILE
1722

1823
# Overwrite the original SQL file with the modified version
1924
mv $TEMP_FILE $SQL_FILE
2025

21-
echo "Placeholders replaced in the SQL file."
26+
echo "Placeholders replaced in $SQL_FILE"
27+
28+
# Print the content of the SQL file to check its values
29+
echo "Checking the modified SQL file:"
30+
ls -l $SQL_FILE
2231

2332
# Step 1: Link to the Supabase project
2433
echo "Linking to Supabase project..."
25-
npx supabase link --project-ref $SUPABASE_REFERENCE_ID > /dev/null 2>&1
34+
npx supabase link --project-ref $SUPABASE_REFERENCE_ID
2635

2736
# Check if linking was successful
2837
if [ $? -ne 0 ]; then
@@ -38,11 +47,12 @@ ENCODED_PASSWORD=$(node -e "console.log(encodeURIComponent(process.argv[1]))" "$
3847
SUPABASE_DATABASE_URL_WITH_PASSWORD=${SUPABASE_DATABASE_URL/\[YOUR-PASSWORD\]/$ENCODED_PASSWORD}
3948

4049
echo "Pushing database changes to Supabase..."
41-
npx supabase db push --db-url "$SUPABASE_DATABASE_URL_WITH_PASSWORD" > /dev/null 2>&1
50+
npx supabase db push --db-url "$SUPABASE_DATABASE_URL_WITH_PASSWORD"
4251

4352
# Check if db push was successful
4453
if [ $? -ne 0 ]; then
4554
echo "Failed to push database changes to Supabase."
55+
exit 1
4656
fi
4757

4858
echo "Supabase operations completed successfully."

0 commit comments

Comments
 (0)