Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Cloudflare's new SQLite database D1 #13310

Open
mikecann opened this issue May 12, 2022 · 41 comments
Open

Support for Cloudflare's new SQLite database D1 #13310

mikecann opened this issue May 12, 2022 · 41 comments
Assignees
Labels
domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/feature A request for a new feature. status/is-preview-feature This feature request is currently available as a Preview feature. topic: Cloudflare Workers topic: connector topic: d1 Issues related to Cloudflare D1 topic: driverAdapters topic: edge topic: @prisma/adapter-d1 topic: serverless topic: sqlite

Comments

@mikecann
Copy link

Cloudflare have just announced their first relational DB D1 which is based on SQLite.

https://blog.cloudflare.com/introducing-d1/

Would be awesome if Prisma could support it one day..

@Weakky Weakky added kind/improvement An improvement to existing feature and code. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. topic: Cloudflare Workers labels May 14, 2022
@mkuchak
Copy link

mkuchak commented May 21, 2022

That would be a really great feature to have

@janpio janpio added kind/feature A request for a new feature. and removed kind/improvement An improvement to existing feature and code. labels May 23, 2022
@jgb-solutions
Copy link

Just came here for this. This will be epic!

@liamross
Copy link

liamross commented Jun 15, 2022

D1 is based on SQLite so it may work by default?

Edit: nevermind (see this HN comment)

@fredgig
Copy link

fredgig commented Aug 2, 2022

Can we expect to see a first iteration in the near future, or should we not hold our breath? I am planning to port a few projects to run fully on Cloudflare D1 in the coming months, and no support from Prisma would mean that I have to start using other ORMs.

@mikecann
Copy link
Author

mikecann commented Aug 3, 2022

Can we expect to see a first iteration in the near future, or should we not hold our breath? I am planning to port a few projects to run fully on Cloudflare D1 in the coming months, and no support from Prisma would mean that I have to start using other ORMs.

As far as im aware D1 still isnt GA

@marcus-sa
Copy link

Can we expect to see a first iteration in the near future, or should we not hold our breath? I am planning to port a few projects to run fully on Cloudflare D1 in the coming months, and no support from Prisma would mean that I have to start using other ORMs.

As far as im aware D1 still isnt GA

It's still closed beta.

@DaniAkash
Copy link

D1 is based on SQLite so it may work by default?

Edit: nevermind (see this HN comment)

As per the new blog post from cloudflare at https://blog.cloudflare.com/whats-new-with-d1/

When running wrangler dev -–local -–persist, an SQLite file will be created inside .wrangler/state. You can then use a local GUI program for managing it, like SQLiteFlow (https://www.sqliteflow.com/) or Beekeeper (https://www.beekeeperstudio.io/).

So, we can get the sqlite db locally & using that, we should be able to use prisma without any additional setup only on development. Just need to implement a connection for production

@buzinas
Copy link

buzinas commented Oct 18, 2022

Any guidance on how to create a connection for production?

@uceumice
Copy link

uceumice commented Nov 8, 2022

Any guidance on how to create a connection for production?

I could imagine creating a separate worker to act as a network adapter between Prisma and D1. Other option, if possible at all, is to pass the instance of D1 (provided via binding) directly to the prisma client.

Notice, the first approach would allow to use D1 outside workers as well, so probably a more scalable option) At the same time, because the solution would involve workers, I could imagine Cloudflare recognising the need for network connections to the D1 and rolling out a more optimised solution. So, let’s wait a bit and watch where things move.

Right now there is not much on guidance, because D1 is still in closed beta.

[Now I've read their recent blog post on procedures, maybe there could be a way to provide Prisma client via the procedures binding, although, I believe the whole idea of procedures could be used as a more fine tuned abstraction then a simple ORM. To me it seems that a connector to D1 would be not worth its value. As of now, it does not seem like Cloudflare team would have something traditional and down to earth in mind. They work on their own serverless edge world which an ORM like Prisma would certainly limit a lot. Build new tools or wait for new tools to be built)]

@janpio janpio changed the title Prisma support for CloudFlares new SQLite database D1 Support for CloudFlares new SQLite database D1 Nov 12, 2022
@damianesteban
Copy link

It looks like Cloudflare opened up the D1 beta today to more users. This would provide a lot of value. If anyone needs me to test anything and/or work on the adapter let me know.

@jgb-solutions
Copy link

+1 for D1 support from Prisma.

@laiso
Copy link

laiso commented Nov 20, 2022

I think uceumice's comment is practical and interesting way how to integrate prisma-client to D1. Prisma-internal has DataProxyEngine and recommends it for serverless environments like Cloudflare Workers and Deno Deploy. maybe if it can self-host Data Proxy API and develop a module to access own database, it might be the first way to integrate with D1.

@DaniAkash
Copy link

D1 is now available as an open alpha, i'll be looking into possible ways to use Prisma without the production driver - like extracting the underlying query from the prisma client using the approach from #5026 (comment)

@balupton
Copy link

balupton commented Nov 29, 2022

@DaniAkash keep us posted!

Also keen to hear official word from either Cloudflare or Prisma... I imagine, as Cloudflare offers a first-class S3 interface for R2, they would offer a first-class Prisma interface for Prisma.

Relevant reading:

@damianesteban
Copy link

@laiso I agree that sounds like a good approach. I’m going to play around with it next week.

@derekhearst
Copy link

I would also love to have Prisma support in d1, it would let me move my entire stack into cloudflare

@DaniAkash
Copy link

DaniAkash commented Jan 11, 2023

@balupton update on my personal project,

I couldn't get the underlying Prisma queries effectively without sacrificing good DX. Ended up refactoring most of my code to kysely along with their D1 dialect. Similar approach was recommended for PlanetScale edge driver as well

Looking forward to see how Prisma will support Cloudflare D1 in the future

@darasus

This comment was marked as abuse.

@jahir9991

This comment was marked as abuse.

@Velka-DEV
Copy link

There is any news about this ?

@janpio
Copy link
Member

janpio commented Jul 31, 2023

No, not yet. We will post an update when we start work or have something to share or test.

@ansbr
Copy link

ansbr commented Aug 3, 2023

No, not yet. We will post an update when we start work or have something to share or test.

We hope that will be very soon! 😉

@sergiocarneiro
Copy link

When you announced you would be partnering with Cloudflare and called "Data DX" I was hoping this would be included

@emircanerkul
Copy link

+1

@MarkBennett
Copy link

Not to be that grumpy old person, but can I point out that commenting "+1" generates a lot of spam for those of us following many issues like this. To show your support, can you please react to the original issue with the 👍🏼 emoji?

If you're just looking to get updates, you can do so without leaving a comment by using the "Subscribe" button near the top of this issue.

Thanks for your understanding! ❤️

@janpio
Copy link
Member

janpio commented Sep 13, 2023

Hey, we at Prisma have been working on the foundations for Edge Functions support for the past few weeks - the basis that will be required for supporting Cloudflare D1. Soon, we'll have something to share and test! If you are interested in helping us, please respond to this super short survey and leave your email address so we can get in touch with instructions: https://pris.ly/survey/driver-adapter-d1 Thanks.

@xdivby0
Copy link

xdivby0 commented Sep 24, 2023

Just subscribed to that survey. Hope that we'll get something soon.

In this prisma docs it says that workers can't use TCP and that's why we need a data-proxy. That was true, but this isn't the case anymore (I guess you aware of this already, though).

Which means the thing that's just missing is that we can connect to an internet URL instead of a file: URL, because sqlite driver on its own is already working for prisma.

@TimKieu
Copy link

TimKieu commented Sep 28, 2023

I love Cloudflare eco system and Prisma.
I am also porting CRM HRM ERP Nodejs/Express/Prisma backends to CFWorkers/Hono/Prisma and D1/serverless-Postgresql.
However, D1 is still in Alpha quite long and with limited things, Cloudflare should change to serverless Postgresql like Vercel/Neon/Supabase or PlanetScale/TiDB MySql and NoSQL space which lead the production and business trends better.

@mustafaersoyer
Copy link

is there any news about this ?

@xdivby0
Copy link

xdivby0 commented Nov 28, 2023

Just subscribed to that survey. Hope that we'll get something soon.

In this prisma docs it says that workers can't use TCP and that's why we need a data-proxy. That was true, but this isn't the case anymore (I guess you aware of this already, though).

Which means the thing that's just missing is that we can connect to an internet URL instead of a file: URL, because sqlite driver on its own is already working for prisma.

For everyone reading this at a later point in time, I haven't received any answer from the survey after 2 months yet and we haven't heard back from the prisma team about if my assumptions about what's needed are correct.

I'd appreciate it a lot if a prisma staff member would update issues like this from time to time.

I know that we are in no way entitled to that, I just think I speak for so many developers when I say that a little transparency about the status would be really appreciated. If not, we'll have to deal with that as well of course it's your product, not ours.

Side note: I'd even be willing to put money where my mouth is if there was a possibility to support/donate to very specific work (for example making prisma compatible with d1 and ready to be used by cf workers).

@anhtuank7c
Copy link

I think I can't wait for it.
Just switch to https://orm.drizzle.team/docs/quick-sqlite/d1

@matbrgz
Copy link

matbrgz commented Jan 6, 2024

I understand that Cloudflare D1 is currently in beta, but it was generous usage limits. While notifications about this issue can be somewhat repetitive, it's crucial to keep the community informed about such developments, any news?. The support for Cloudflare D1 would indeed be a significant step forward for Prisma and its users.

@itsmegood
Copy link

itsmegood commented Jan 7, 2024

I asked this question on the prisma discord, they said no estimate date will have to wait for it but they are working on it.

P.S - They said to fill in the survey they will add you on the wait list they will let us know if they have something
Slow but we can't do anything except either switch or wait for a good while

@hrueger
Copy link

hrueger commented Jan 7, 2024

I've tried building a D1 adapter, however, there are some pieces missing which I cannot figure out how to do (like infering types and transactions in general). If one of you knows D1 / Sqlite / Prisma Adapters better than me (which shouldn't be too hard 😅), feel free to check out the fork. I've enabled issues on that repository so we can keep the noise in this thread to a minimum 👍
You don't need a cloudflare account since it is using miniflare for testing.

@janpio
Copy link
Member

janpio commented Mar 16, 2024

Quick update: We are currently testing the D1 adapter with a selected number of users via an Early Access. If you want to participate, just go by https://pris.ly/survey/driver-adapter-d1 again and leave a response where you only select D1 as the database you are interested in an I can prioritize inviting you for this as well. Thanks!

@janpio janpio added the status/is-preview-feature This feature request is currently available as a Preview feature. label Apr 8, 2024
@janpio
Copy link
Member

janpio commented Apr 8, 2024

Hey, last week we released Prisma ORM version 5.12.x which includes support for Cloudflare D1, behind the preview feature flag driverAdapters.

Please give it a try, and leave your feedback in our Cloudflare D1 feedback discussion. 🚀

@janpio janpio added topic: @prisma/adapter-d1 topic: d1 Issues related to Cloudflare D1 labels Apr 8, 2024
@prisma prisma locked as resolved and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/feature A request for a new feature. status/is-preview-feature This feature request is currently available as a Preview feature. topic: Cloudflare Workers topic: connector topic: d1 Issues related to Cloudflare D1 topic: driverAdapters topic: edge topic: @prisma/adapter-d1 topic: serverless topic: sqlite
Projects
None yet
Development

No branches or pull requests