1
1
#! /bin/bash
2
- set + x
2
+ set - x
3
3
4
4
# Step 0: Replace placeholders in the SQL file
5
- # Path to the original SQL file
6
- SQL_FILE=" supabase/migrations/20240108234540_setup.sql"
7
-
8
5
# Temporary file for storing the modified SQL file
9
6
TEMP_FILE=" temp.sql"
10
7
8
+ # Path to the original SQL file
9
+ SQL_FILE=" supabase/migrations/20240108234540_setup.sql"
10
+ ls -l $SQL_FILE
11
+
11
12
# Environment variables (these should be set in your Railway environment or .env file)
12
13
PROJECT_URL=${NEXT_PUBLIC_SUPABASE_URL:- http:// localhost: 8000}
13
14
SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY:- your_default_service_role_key}
14
15
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
17
22
18
23
# Overwrite the original SQL file with the modified version
19
24
mv $TEMP_FILE $SQL_FILE
20
25
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
22
31
23
32
# Step 1: Link to the Supabase project
24
33
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
26
35
27
36
# Check if linking was successful
28
37
if [ $? -ne 0 ]; then
@@ -38,11 +47,12 @@ ENCODED_PASSWORD=$(node -e "console.log(encodeURIComponent(process.argv[1]))" "$
38
47
SUPABASE_DATABASE_URL_WITH_PASSWORD=${SUPABASE_DATABASE_URL/ \[ YOUR-PASSWORD\] / $ENCODED_PASSWORD }
39
48
40
49
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 "
42
51
43
52
# Check if db push was successful
44
53
if [ $? -ne 0 ]; then
45
54
echo " Failed to push database changes to Supabase."
55
+ exit 1
46
56
fi
47
57
48
58
echo " Supabase operations completed successfully."
0 commit comments