File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 4646# Run Supabase setup and migrations on the remote server
4747echo -e " ${YELLOW} Running Supabase setup and migrations on remote server...${NC} "
4848
49- # Run the Supabase setup
50- echo -e " ${YELLOW} Running Supabase setup on remote server ...${NC} "
49+ # Run the Supabase setup to ensure proper database association
50+ echo -e " ${YELLOW} Running Supabase setup to link with correct database ...${NC} "
5151ssh $SSH_OPTS $REMOTE_USER @$REMOTE_HOST " cd $REMOTE_DIR && chmod +x ./bin/supabase-db.sh && ./bin/supabase-db.sh setup"
5252
5353if [ $? -ne 0 ]; then
5454 echo -e " ${RED} Supabase setup failed. Aborting deployment.${NC} "
55+ echo -e " ${YELLOW} This usually means the project could not be linked to the correct database.${NC} "
56+ echo -e " ${YELLOW} Please check your SUPABASE_ACCESS_TOKEN and SUPABASE_DB_PASSWORD in the .env file.${NC} "
57+ exit 1
58+ fi
59+
60+ # Verify the project is properly linked before running migrations
61+ echo -e " ${YELLOW} Verifying Supabase project is properly linked...${NC} "
62+ ssh $SSH_OPTS $REMOTE_USER @$REMOTE_HOST " cd $REMOTE_DIR && ./bin/supabase-db.sh setup"
63+
64+ if [ $? -ne 0 ]; then
65+ echo -e " ${RED} Supabase project linking verification failed. Aborting deployment.${NC} "
66+ echo -e " ${YELLOW} The local config may differ from the linked project.${NC} "
67+ echo -e " ${YELLOW} Try updating supabase/config.toml or re-linking the project.${NC} "
5568 exit 1
5669fi
5770
Original file line number Diff line number Diff line change @@ -568,7 +568,12 @@ function generateServerMigration(args) {
568568 // Suggest next steps
569569 console . log ( '\nNext steps:' ) ;
570570 console . log ( '1. Edit the migration file to add your SQL commands' ) ;
571- console . log ( '2. Apply the migration using Supabase CLI or your deployment process' ) ;
571+ console . log ( '2. For local development:' ) ;
572+ console . log ( ' - Link project: supabase link --project-ref <your-project-ref>' ) ;
573+ console . log ( ' - Apply migration: supabase db push' ) ;
574+ console . log ( '3. For CI/CD deployment:' ) ;
575+ console . log ( ' - Ensure SUPABASE_ACCESS_TOKEN and SUPABASE_DB_PASSWORD are set' ) ;
576+ console . log ( ' - Use: supabase db push --linked in GitHub Actions' ) ;
572577 console . log ( ' Note: Supabase only supports forward migrations (no DOWN methods)' ) ;
573578 } catch ( error ) {
574579 throw error ;
@@ -591,6 +596,11 @@ Usage:
591596Options:
592597 --name Migration name (required, e.g., "add_user_fields" or "AddUserFields")
593598 --help Show this help information
599+
600+ Important Setup Notes:
601+ - For local development: Ensure project is linked with 'supabase link --project-ref <ref>'
602+ - For CI/CD deployments: Set SUPABASE_ACCESS_TOKEN and SUPABASE_DB_PASSWORD in secrets
603+ - If you see "Local config differs from linked project", update supabase/config.toml
594604 ` ) ;
595605}
596606
You can’t perform that action at this time.
0 commit comments