Support databases without foreign keys #7293
Labels
kind/feature
A request for a new feature.
team/schema
Issue for team Schema.
topic: database-functionality
topic: database-provider/planetscale
topic: foreign keys
topic: introspection
topic: migrate
Milestone
Problem
There are databases that do not use foreign keys, for example PlanetScale that disallows them to be able to support Non Blocking Schema changes, MySQL MyISAM that just is to old and works well without, and many user databases where a choice was made not to use foreign keys as a concept for various reasons (Rails did not do a great job with them for quite some time and worked fine without, some people prefer to handle the referential integrity and actions manually in their app, for example to improve performance).
Right now Prisma does not work well with these database: Prisma Migrate will try to create foreign keys for relations by default, and Introspection will only introspect relations based on foreign keys. You can theoretically add relations to your Prisma schema without the backing foreign keys as long as the correct fields are present, but any Re-Introspection would remove these manually added relations from the schema file again.
Suggested solution
Introduce a configuration that allows Prisma to not user foreign keys. Prisma Migrate should not create them, Introspection should not drop relations if there are no foreign keys. Prisma Client should work the same as it does when using foreign keys.
Alternatives
Additional context
Referential integrity and actions are closely related to this topic, but separate.
The text was updated successfully, but these errors were encountered: