From 1e34c7594d628eba6c7aba9c336b7a4a7aa85cd3 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Fri, 24 Feb 2023 11:32:44 +0100 Subject: [PATCH] chore(views): Add headline for adding unique identifier --- .../01-prisma-schema/08-views.mdx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/content/200-concepts/100-components/01-prisma-schema/08-views.mdx b/content/200-concepts/100-components/01-prisma-schema/08-views.mdx index a202c719a6..5c3c2db2b1 100644 --- a/content/200-concepts/100-components/01-prisma-schema/08-views.mdx +++ b/content/200-concepts/100-components/01-prisma-schema/08-views.mdx @@ -253,7 +253,17 @@ view UserInfo { The `view` block is generated initially with a `@@ignore` attribute because [there is no unique identifier defined](#unique-identifier) (which is currently a [limitation](#unique-identifier) of the views preview feature). -In this view's case, the `id` column refers to a uniquely identifiable field in the underlying `User` table so that field will also be used as the uniquely identifiable field in the `view` block. + + +Please note for now `db pull` will only introspect views in your schema when using PostgreSQL. Support for this workflow will be extended to other database providers soon. + + + +#### Adding a unique identifier to an introspected view + +To be able to use the introspected view in Prisma Client, you will need to select and define one or multiple of the fields as the unique identifier. + +In the above view's case, the `id` column refers to a uniquely identifiable field in the underlying `User` table so that field can also be used as the uniquely identifiable field in the `view` block. In order to make this `view` block valid you will need to: @@ -277,12 +287,6 @@ view UserInfo { When re-introspecting your database, any custom changes to your view definitions will be preserved. - - -Please note for now `db pull` will only introspect views in your schema when using PostgreSQL. Support for this workflow will be extended to other database providers soon. - - - ### Limitations #### Unique Identifier