Skip to content

Commit d8a4f5b

Browse files
committed
Remove IPv4 forcing and simplify database connection handling in deploy scripts
1 parent 6ad406d commit d8a4f5b

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

bin/deploy-with-migrations.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ REMOTE_PORT="${DEPLOY_REMOTE_PORT:-2048}"
2323
REMOTE_USER="${DEPLOY_REMOTE_USER:-ubuntu}"
2424
REMOTE_DIR="${DEPLOY_REMOTE_DIR:-www/profullstack.com/pdf}"
2525

26-
# Create SSH options - force IPv4 to avoid IPv6 connection issues
27-
SSH_OPTS="-4 -p $REMOTE_PORT"
26+
# Create SSH options
27+
SSH_OPTS="-p $REMOTE_PORT"
2828

2929
# Deploy the code first using deploy.sh
3030
echo -e "${YELLOW}Running deployment script...${NC}"

bin/deploy.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ REMOTE_DIR="${DEPLOY_REMOTE_DIR:-www/profullstack.com/pdf}"
1616
LOCAL_DIR="."
1717
INSTALL_SERVICE="${INSTALL_SERVICE:-false}"
1818

19-
# Create SSH options - force IPv4 to avoid IPv6 connection issues
20-
SSH_OPTS="-4 -p $REMOTE_PORT"
21-
SCP_OPTS="-4 -P $REMOTE_PORT"
22-
RSYNC_OPTS="-e \"ssh -4 -p $REMOTE_PORT\""
19+
# Create SSH options
20+
SSH_OPTS="-p $REMOTE_PORT"
21+
SCP_OPTS="-P $REMOTE_PORT"
22+
RSYNC_OPTS="-e \"ssh -p $REMOTE_PORT\""
2323

2424
# Set colors for output
2525
GREEN='\033[0;32m'
@@ -42,10 +42,10 @@ if ssh $SSH_OPTS $REMOTE_USER@$REMOTE_HOST "[ -d $REMOTE_DIR ]"; then
4242
# Deploy using rsync with .deployignore
4343
if [ -f .deployignore ]; then
4444
echo -e "${YELLOW}Using .deployignore file for exclusions...${NC}"
45-
rsync -avz --partial --progress -e "ssh -4 -p $REMOTE_PORT" --exclude-from=.deployignore $LOCAL_DIR $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR
45+
rsync -avz --partial --progress -e "ssh -p $REMOTE_PORT" --exclude-from=.deployignore $LOCAL_DIR $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR
4646
else
4747
echo -e "${YELLOW}No .deployignore file found. Excluding node_modules/ by default...${NC}"
48-
rsync -avz --partial --progress -e "ssh -4 -p $REMOTE_PORT" --exclude="node_modules/" $LOCAL_DIR $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR
48+
rsync -avz --partial --progress -e "ssh -p $REMOTE_PORT" --exclude="node_modules/" $LOCAL_DIR $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR
4949
fi
5050

5151
# Check if rsync was successful

bin/supabase-db.sh

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,8 @@ setup_project() {
213213
export PGPASSWORD="$SUPABASE_DB_PASSWORD"
214214

215215
# Run the link command directly - no retries to avoid confusion
216-
# Add GODEBUG=netdns=4 to force IPv4 DNS resolution
217-
echo -e "${YELLOW}Running: GODEBUG=netdns=4 supabase link --project-ref \"$PROJECT_REF\" --password \"$SUPABASE_DB_PASSWORD\" --debug${NC}"
218-
GODEBUG=netdns=4 supabase link --project-ref "$PROJECT_REF" --password "$SUPABASE_DB_PASSWORD" --debug
216+
echo -e "${YELLOW}Running: supabase link --project-ref \"$PROJECT_REF\" --password \"$SUPABASE_DB_PASSWORD\" --debug${NC}"
217+
supabase link --project-ref "$PROJECT_REF" --password "$SUPABASE_DB_PASSWORD" --debug
219218

220219
if [ $? -eq 0 ]; then
221220
echo -e "${GREEN}Link successful!${NC}"
@@ -276,31 +275,12 @@ run_migrations() {
276275
echo -e "${YELLOW}Using hardcoded project reference as fallback: $PROJECT_REF${NC}"
277276
fi
278277

279-
# Set up the database URL for direct cloud connection
280-
# Force IPv4 by resolving the hostname to an IPv4 address
281-
echo -e "${YELLOW}Resolving db.${PROJECT_REF}.supabase.co to IPv4 address...${NC}"
282-
DB_HOST=$(getent ahostsv4 db.${PROJECT_REF}.supabase.co | head -n 1 | awk '{print $1}')
278+
# Use the Supabase CLI to push migrations without direct database connection
279+
echo -e "${YELLOW}Running migrations using Supabase CLI...${NC}"
283280

284-
if [ -z "$DB_HOST" ]; then
285-
echo -e "${YELLOW}Failed to resolve IPv4 address, using hostname...${NC}"
286-
DB_HOST="db.${PROJECT_REF}.supabase.co"
287-
else
288-
echo -e "${YELLOW}Using IPv4 address: $DB_HOST${NC}"
289-
fi
290-
291-
DB_URL="postgresql://postgres:${SUPABASE_DB_PASSWORD}@$DB_HOST:5432/postgres"
292-
echo -e "${YELLOW}Using cloud database URL for migrations...${NC}"
293-
294-
# Run the migration command directly with the cloud database URL
295-
echo -e "${YELLOW}Running migrations on cloud database...${NC}"
296-
297-
# Set up PGPASSWORD environment variable
298-
export PGPASSWORD="$SUPABASE_DB_PASSWORD"
299-
300-
# Run the command with the cloud database URL - no retries to avoid confusion
301-
# Add GODEBUG=netdns=4 to force IPv4 DNS resolution
302-
echo -e "${YELLOW}Running: GODEBUG=netdns=4 supabase db push --db-url <DB_URL> --debug${NC}"
303-
GODEBUG=netdns=4 supabase db push --db-url "$DB_URL" --debug
281+
# Run the command without direct database URL to use the linked project
282+
echo -e "${YELLOW}Running: supabase db push${NC}"
283+
supabase db push
304284

305285
if [ $? -eq 0 ]; then
306286
echo -e "${GREEN}Migration successful!${NC}"

0 commit comments

Comments
 (0)