- CockroachDB support in Prisma is now in Preview
- Prisma - making databases easy
- Why Prisma & CockroachDB
- Getting started
- Try Prisma with your existing CockroachDB database and share your feedback
CockroachDB is a distributed SQL database that shines in its ability to scale efficiently while maintaining developer agility and reducing operational overhead.
CockroachDB support in Prisma is the product of collaboration with the Cockroach Labs team. It has passed rigorous testing internally and is now ready for broader testing by the community.
Your feedback and suggestions will help us shape the future of CockroachDB support in Prisma. 🙌
It can be used as an alternative to traditional ORMs and SQL query builders to interact with your database.
It consists of the following tools:
- Prisma Client: Auto-generated and type-safe database client
- Prisma Migrate: Declarative data modeling and auto-generated SQL migrations
- Prisma Studio: Modern UI to view and edit data
Note: With this Preview release, Prisma Migrate is not supported yet.
To learn more about Prisma, check out the documentation.
Ensuring confidence and developer productivity with databases is at the core of our mission at Prisma. But as an ORM, Prisma is agnostic to how you operate your relational database; this is where CockroachDB comes in.
While Prisma helps you reap significant productivity gains throughout the design, review, and implementation phases of database-driven applications, operating and scaling a relational database demands specialized knowledge and attention.
Traditional relational databases like PostgreSQL were designed and built long before the cloud-native era without native horizontal scaling features.
CockroachDB, in contrast, was designed from the offset as a distributed database with automated scaling, failover, and repair at its core. It can be self-hosted on your infrastructure or used as a hosted service with dedicated and serverless offerings.
This is in line with the general shift of the industry toward managed infrastructure as a means to reduce costs; and our vision to unlock the potential of serverless architectures, which we presented at the Prisma Serverless Data Conference.
Since CockroachDB maintains a high degree of PostgreSQL compatibility, some Prisma users were already using the Prisma PostgreSQL connector with CockroachDB. However, we learned that there are subtle differences between CockroachDB and PostgreSQL and decided to invest in a dedicated CockroachDB connector for full support.
With today's release, you can use introspection to populate your Prisma schema and Prisma Client to interact with the database in a type-safe manner.
We have started the design work on schema migrations with Prisma Migrate and CockroachDB so that we can bring CockroachDB support to General Availability.
To learn more about CockroachDB Serverless and how it fits together with Prisma, check out Aydrian Howard's talk from the Prisma Serverless conference:
This release allows you to use Prisma Client with an existing CockroachDB database, using the introspection flow.
To enable the Preview feature, add
previewFeatures in your Prisma schema.
With Prima's introspection workflow, you begin by introspecting (
prisma db pull) an existing CockroachDB database that populates the Prisma schema with models mirroring the state of your database schema.
Then you can generate Prisma Client (
prisma generate) and interact with your database in a type-safe manner with Node.js or TypeScript.
Note that CockroachDB Serverless comes with a generous free-tier (5GB Storage, 250M Request Units/month) so you can experiment and test in a matter of a few clicks.
Get started with Prisma and CockroachDB
Prisma Migrate is not supported yet with CockroachDB; if you're starting without an existing database, you will need to define the schema with SQL. To follow progress on this, subscribe to the related issue.
We are working on adding support for CockroachDB in Prisma Migrate, which will be available soon; and fully supported when the CockroachDB connector is Generally Available.
CockroachDB supports the PostgreSQL wire protocol and the majority of PostgreSQL syntax. However, there are some nuanced differences with regards to types. To learn more about the Prisma specific differences, check out the Prisma CockroachDB connector docs:
Read the Prisma CockroachDB connector docs
We built this for you and are eager to hear your feedback!
🐜 Found something you'd love to see improved? Please file an issue so our engineering team can look into it.
🌍 We also invite you to join our Slack where you can discuss all things Prisma, share general product feedback in the
#product-feedback channel and get help from the community.
Get started with Prisma and CockroachDB