effect icon indicating copy to clipboard operation
effect copied to clipboard

From Discord: Incompatibility of `SqlMessageStorage` with Vitess Databases Due to Foreign Key Constraints

Open effect-bot opened this issue 2 months ago • 1 comments

Summary

The SqlMessageStorage implementation currently uses a recursive foreign key constraint (messages.requestId -> messages.id) with ON DELETE CASCADE, which is incompatible with Vitess databases like Planetscale due to their restrictions on foreign keys. The conversation highlights Vitess' specific rules against such foreign keys (https://vitess.io/docs/22.0/user-guides/vschema-guide/foreign-keys/). This issue does not seem to affect standard Postgres databases on Planetscale. A potential solution discussed is to remove the ON DELETE CASCADE requirement by introducing a closure table to manage parent-child relationships between messages, enabling controlled cascading deletions without violating Vitess constraints. The user is willing to assist in developing this solution.

Discord thread

https://discord.com/channels/795981131316985866/1425409435718652055

effect-bot avatar Oct 23 '25 06:10 effect-bot

Cluster in v4 doesn't use foreign keys anymore, this issue can be closed

Brendonovich avatar Nov 05 '25 07:11 Brendonovich