惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 【当耐特】
The Cloudflare Blog
B
Blog
Last Week in AI
Last Week in AI
小众软件
小众软件
量子位
S
SegmentFault 最新的问题
V
Visual Studio Blog
博客园 - 叶小钗
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
A
About on SuperTechFans
雷峰网
雷峰网
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Martin Fowler
Martin Fowler

Blog — PlanetScale

Keeping a Postgres queue healthy — PlanetScale Patterns for Postgres Traffic Control — PlanetScale Graceful degradation in Postgres — PlanetScale High memory usage in Postgres is good, actually — PlanetScale Stripe Projects partnership: Provision PlanetScale Postgres and MySQL databases from the Stripe CLI — PlanetScale Enhanced tagging in Postgres Query Insights — PlanetScale Behind the scenes: How Database Traffic Control works — PlanetScale Introducing Database Traffic Control — PlanetScale Scaling Postgres connections with PgBouncer — PlanetScale Drizzle joins PlanetScale — PlanetScale Video Conferencing with Postgres — PlanetScale Faster PlanetScale Postgres connections with Cloudflare Hyperdrive — PlanetScale Introducing the PlanetScale MCP server — PlanetScale Database Transactions — PlanetScale Automating our changelog with Cursor commands — PlanetScale Postgres 18 is now available — PlanetScale Using MotherDuck with PlanetScale — PlanetScale $50 PlanetScale Metal is GA for Postgres — PlanetScale AI-Powered Postgres index suggestions — PlanetScale $5 PlanetScale is live — PlanetScale Announcing Vitess 23 — PlanetScale $50 PlanetScale Metal — PlanetScale Report on our investigation of the 2025-10-20 incident in AWS us-east-1 — PlanetScale $5 PlanetScale — PlanetScale Benchmarking Postgres 17 vs 18 — PlanetScale Larger than RAM Vector Indexes for Relational Databases — PlanetScale Partnering with Cloudflare to bring you the fastest globally distributed applications — PlanetScale Processes and Threads — PlanetScale PlanetScale for Postgres is now GA — PlanetScale Postgres High Availability with CDC — PlanetScale
Announcing foreign key constraints support — PlanetScale
Taylor Barnett · 2023-12-05 · via Blog — PlanetScale

Taylor Barnett |

Today, we're adding support for foreign key constraints on PlanetScale!

We understand that making database changes can be a daunting task. Now, you can use PlanetScale without reworking your existing application or data model to remove foreign key constraints. You can also use PlanetScale out of the box with your favorite ORM or framework that uses foreign key constraints by default, no changes needed.

You no longer have to sacrifice foreign key constraints when using database branching, non-blocking schema changes with Online DDL, database imports, and scaling your database with PlanetScale.

What is a foreign key constraint?

A foreign key constraint is a database construct and implementation that enforces the integrity of foreign key relationships (referential integrity). Specifically, it ensures that a child table can only reference a parent table when the appropriate row exists in the parent table. This is not to be confused with foreign keys, which allow you to cross-reference related data across tables.

Developers should weigh the advantages and disadvantages of using foreign key constraints for their specific application, which are discussed further in the foreign key constraints documentation.

If you want a behind-the-scenes look into foreign key constraints in PlanetScale, read our blog post about the technical challenges of supporting foreign key constraints.

Foreign key constraints beta

Note

Update: Foreign key constraint support is now GA. You can enable foreign key constraint support in your database settings page.

The new foreign key constraints support is available today in beta on a per-database level for all unsharded databases. Sharded database support will come next year. When you opt in to the beta, we upgrade your Vitess cluster, and in some cases, we upgrade the MySQL version.

To opt in to an existing database, go to your database's "Settings" page and enroll on the "Beta features" page. Note: You must be an organization administrator to enroll in beta features.

On the database's "Overview" page, you will see a loading spinner that says it is "Enabling foreign key constraints." Once it no longer shows, you can use foreign key constraints in your PlanetScale database!

Warning

If you want to unenroll your database from the beta, make sure to first drop your foreign key constraints. We do not downgrade your database at this time.

Most users with newer databases can use foreign key constraints within minutes. Older databases may take longer.

If you have existing internet-accessible MySQL or MariaDB databases that use foreign key constraints, you can also now import them into PlanetScale using our database import tool.

For more details about the beta, see the foreign key constraints beta documentation.

Try it out today

We have tested the beta with various popular ORMs and frameworks, but if you experience any issues with your ORM or framework of choice, let us know! While we are in this beta phase, it is helpful to hear about any problems you experience using foreign key constraints in PlanetScale. Please contact us if you have anything to share or have any questions.