DEV Community

Cover image for How I Migrated My PostgreSQL Database from Render to Supabase
moondevlog
moondevlog

Posted on

How I Migrated My PostgreSQL Database from Render to Supabase

A real-world migration log from a full-stack project (React + Spring Boot) — with all the mistakes I made and how I fixed them.


📚 Table of Contents

  1. Introduction
  2. Why Supabase?
  3. Project Architecture Overview
  4. Setting Up Supabase
  5. Connecting Spring Boot to Supabase
  6. Pitfalls & Lessons: My Supabase Migration Mistakes
  7. Final Thoughts: Free Hosting for Full-Stack Portfolios

🏁 1. Introduction

I built a full-stack demo project using React + Spring Boot + PostgreSQL. Initially, I hosted my backend and database on Render. However, its free PostgreSQL database expires after 30 days.

I needed a long-term free alternative — that’s when I found Supabase.


💡 2. Why Supabase?

  • Free permanent tier
  • 100% compatible with PostgreSQL
  • Easy to manage via a modern UI
  • Quick setup for small projects

🧱 3. Project Architecture Overview

  • Frontend: React + Material UI (hosted on Vercel)
  • Backend: Spring Boot (hosted on Render)
  • Database: Supabase PostgreSQL
  • Structure:
    • entity (JPA models)
    • repository (Spring Data JPA)
    • controller (REST API)
    • config (security, DB)

⚙️ 4. Setting Up Supabase

  1. Create a new project
  2. Set a strong database password and region
  3. Get DB credentials from Settings->Database

🔌 5. Connecting Spring Boot to Supabase

🌐 In your Render Environment Variables:

DB_URL=jdbc:postgresql://<host>:6543/postgres?sslmode=require
DB_USERNAME=postgres.<project-ref>
DB_PASSWORD=<your-password>
Enter fullscreen mode Exit fullscreen mode

⚙️ Spring Boot application.properties

spring.datasource.url=${DB_URL}
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}
spring.datasource.driver-class-name=org.postgresql.Driver
Enter fullscreen mode Exit fullscreen mode

✅ Use Pooler host
✅ Use port 6543
✅ Use SSL
✅ Don’t use just postgres — copy the full username shown in Supabase.


🧨 6. Pitfalls & Lessons: My Supabase Migration Mistakes

 Error 1: Network is unreachable
Used the default database host  Render couldn't connect
 Fix: Use Pooler host + port 6543

 Error 2: Tenant or user not found
Used wrong username (postgres)
 Fix: Use postgres.<project-ref> from Supabase dashboard

 Tried to manually create tables in Supabase
Hibernate threw schema conflict errors
 Fix: Let Spring Boot create tables automatically on startup
Enter fullscreen mode Exit fullscreen mode

✅ Testing the App & Uploading Data
Once the backend started on Render, Spring Boot successfully connected to Supabase and auto-created the tables via Hibernate.


📦 7. Final Thoughts: Free Hosting for Full-Stack Portfolios

If you’re showcasing projects online, this stack works great — totally free and easy to set up:

Frontend: Vercel

Backend: Render

Database: Supabase

⚠️ Performance Tip:

If your frontend uses a DataGrid or similar component, make sure it supports true server-side pagination.

Otherwise, fetching all rows at once — even with visible pagination — can slow down your app significantly.


Top comments (0)