DEV Community

Prisma + Postgres

awalias on October 30, 2024

In this tutorial, we'll explore how to set up Prisma + Postgres. We'll use real-world examples involving books and authors. Prerequisites...
Collapse
 
awalias profile image
awalias • Edited

If anyone needs help regarding Prisma / Postgres you can get support in our discord

Collapse
 
joshenlim profile image
Joshen Lim

Hopefully this might be helpful - there's a set of handy instructions on your projects' home page if you click the "Connect" button and select the "ORMs" tab
Image description

Collapse
 
supabase_io profile image
Supabase

Yes! Thanks for sharing @joshenlim

Collapse
 
supa_community profile image
Supabase Community

Prisma Postgres is an incredible pairing for a backend. Both tools are used and loved by the Supabase Community.

Collapse
 
timnpalmer profile image
timnpalmer

AMAZING!!

Collapse
 
steve_val profile image
Steve_Val

The memes in there are crazy lol

Also note for anyone else who's wondering the official Prisma documentation related to this is here: prisma.io/docs/orm/overview/databa...

The important step adding

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}
Enter fullscreen mode Exit fullscreen mode

Very nice.

Collapse
 
swamp_dog profile image
swamp_dog

I was trying initially without the direct_url but apparently it's required if you need to do migrations.

Collapse
 
thorwebdev profile image
Thor 雷神

You can also find some details on using Row Level Security (RLS) with Prisma here: supabase.com/partners/integrations...

Collapse
 
jonmeyers_io profile image
Jon

This is an absolute game changer!

Collapse
 
_tylerhillery profile image
Tyler Hillery

The discord is very welcoming to new comers!

Collapse
 
tylerhillery profile image
Tyler Hillery

Prisma + Supabse is an awesome combo.

Collapse
 
chasers profile image
Chase Granberry

💚 Prisma + Supabase

Collapse
 
deji_ibrahim_6039f39d0278 profile image
Deji Ibrahim

Easy to setup 👌, thanks!

Collapse
 
jgoux profile image
Julien Goux

Prisma and Supabase are really a great fit. Great combo!

Collapse
 
sausagebutty profile image
David Wilson

yes yes yes

Collapse
 
sivenruot profile image
Lee AVULAT

Nice guide. I would add that if you want to use prisma to generate migrations. For those to be usable with supabase-js and postgrest I recommend to leverage the native database functions in your "id" definitions like mentioned here: github.com/supabase/cli/issues/277...

Collapse
 
joel_lee_f718aee79f12cef2 profile image
Joel Lee

Thanks, will check it out

Collapse
 
jonmeyers_io profile image
Jon

This is so sick! 💯

Collapse
 
gregnr profile image
Greg Richardson

Super seamless, nice 😃🚀

Collapse
 
dshukertjr profile image
Tyler Shukert

I know a lot of apps built with this combination!

Collapse
 
karloison_27 profile image
Karlo Ison

Awesome! 🤩

Collapse
 
supadavid profile image
SupaDavid

awesome

Collapse
 
canumula profile image
Chandana Anumula

This is great!!

Collapse
 
francesco_sansalvadore_dd profile image
Francesco Sansalvadore

Prisma + Supabase is the perfect combo.

Collapse
 
jessshears profile image
Jessica Shears

This is awesome!

Collapse
 
abc3 profile image
abc3 🇺🇦

Supabase and Prisma makes development so much easier. Love this combo

Collapse
 
flutter_for_life profile image
flutter_for_life

Nice share!

Collapse
 
paul_c_65b1cdb633d134113e profile image
Paul C • Edited

Supabase and Prisma is the perfect match for us, it makes life so easy to build things quickly.

Collapse
 
akorotkov profile image
Alexander Korotkov

Brilliant, thank you!

Collapse
 
imor80 profile image
Raminder Singh

I was just trying out setting up Prisma with Postgres and found this guide. Thanks for writing this.

Collapse
 
raminder_singhsidhu_ea69 profile image
Raminder Singh Sidhu

Thank you so much, this is what I was looking for. A great guide to setup Prisma with Postgres.

Collapse
 
alexander_korotkov_0170b0 profile image
Alexander Korotkov

Thank you!

Collapse
 
grsouza profile image
Guilherme Souza

That is awesome!

Collapse
 
kamil_ogrek_710afe8e9268 profile image
Kamil Ogórek

Always happy to help

Collapse
 
illiab profile image
Illia Basalaiev

This is amazing! 💪💪

Collapse
 
sreyas_udayavarman_496239 profile image
Sreyas Udayavarman

Thankyou!

Collapse
 
samrose_56 profile image
samrose

Thank you so much. I wish I had known how easy this was in the past. Grateful for this resource!

Collapse
 
encima_49 profile image
Chris • Edited

thanks for this! If I am using a pooler like Supavisor does that mean I do not use Accelerate or anything, just the Prisma library and Supabase handles the rest?

Collapse
 
tylerfontaine profile image
Tyler Fontaine

Bingo! You got it

Collapse
 
4l3k51 profile image
Aleksi Immonen

Excellent guide !

Collapse
 
qianl15 profile image
Qian Li

Thanks for the starter tutorial -- it's clear and simple. Things can get tricker if you modify the schema and want to actually push to production:

  • prisma migrate dev is only for dev environment. Use npx prisma migrate deploy for production and testing (CI/CD pipelines). Docs
  • Run npx prisma generate to generate new client code whenever you modify the schema as well.

Also, I noticed that Prisma doesn't really support rolling back schema changes. So to revert changes you need to revert your schema file and generate a "new" migration/client to undo the previous change instead.

Collapse
 
4l3k51 profile image
Aleksi Immonen

Excellent guide!

Collapse
 
davy_c1f0f5e0e5e0 profile image
Dave

This is great!

Collapse
 
codexam profile image
Subham

Interesting guide, but honestly, why go through all this setup with Prisma + Postgres when you could use Drizzle ORM? Drizzle is so much cleaner and more TypeScript friendly without all the heavy migration overhead.

Collapse
 
jonmeyers_io profile image
Jon

What an incredibly powerful stack! Prisma and Postgres powered by Supabase! 🚀

Collapse
 
w3b6x9 profile image
Wen Bo Xie

Excited to use Prisma and Supabase together! This makes it so easy to get started and distinguish between which database connection strings to use and why.

Collapse
 
timnpalmer profile image
timnpalmer

Super valuable guide, thanks

Collapse
 
sreyas_udayavarman_496239 profile image
Sreyas Udayavarman

This is great! Easy to setup.