Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(client): add relationMode datasource property tests for all databases #14221

Merged
merged 141 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
6b7f842
test(client): prototype referential integrity tests
Jolg42 Jul 8, 2022
7413888
exclude mongodb to see if types tests fail like locally
Jolg42 Jul 11, 2022
bd0a3c3
wip rewrite with Alberto
Jolg42 Jul 12, 2022
47a31d7
chore: update tests
jkomyno Jul 12, 2022
9987b3a
chore: used .rejects.toThrowError
jkomyno Jul 13, 2022
d3c53d4
chore: started adding ref actions
jkomyno Jul 13, 2022
a9a7d94
chore: mongodb only supports 'referentialIntegrity: prisma'
jkomyno Jul 13, 2022
400208b
chore: added support for conditional error messages
jkomyno Jul 13, 2022
a03044a
wip
Jolg42 Jul 13, 2022
db89457
fix referentialIntegrityLine
Jolg42 Jul 13, 2022
18e085f
add skeleton for 1:n and m:n tests
Jolg42 Jul 13, 2022
8e7b569
chore: highlighted some test errors with mongodb
jkomyno Jul 13, 2022
d6f9a5c
chore: added create tests for 1:n relationship
jkomyno Jul 14, 2022
8f7fd82
chore: added TODO comment
jkomyno Jul 14, 2022
8b9c18e
WIP m:n for SQL databases
Jolg42 Jul 14, 2022
ebdb7bf
ci: try running github actions matrix with our tests only
Jolg42 Jul 14, 2022
e40dbc4
ci: remove needs: detect_jobs_to_run
Jolg42 Jul 14, 2022
38dd949
ci: fix os matrix
Jolg42 Jul 14, 2022
6d26708
ci: small CI env var tweak
Jolg42 Jul 14, 2022
030cfbf
ci: fix bash line
Jolg42 Jul 14, 2022
9f27286
chore: added some update/delete tests for 1:n
jkomyno Jul 14, 2022
c0ce6bf
chore: added comments to _matrix.ts
jkomyno Jul 14, 2022
39ec0d0
postgresql m:n all referential actions
Jolg42 Jul 14, 2022
6f65b7f
merge main
Jolg42 Jul 15, 2022
5556a6c
Merge remote-tracking branch 'origin/main' into joel/referential-inte…
Jolg42 Jul 15, 2022
550df4c
DEFAULT, exclude Restrict from SQL Server, fix tests
Jolg42 Jul 15, 2022
263997c
add mongodb tests for m:n
Jolg42 Jul 15, 2022
1bffa29
chore: added some additional ref actions, added support for SQL Server
jkomyno Jul 18, 2022
b8aecb4
chore: merge upstream, fix conflicts
jkomyno Jul 18, 2022
dfc5153
chore: fixed bug with DEFAULT not tested, added upsert test, fixed so…
jkomyno Jul 19, 2022
3c2e5a8
reuse sql schema for mongodb 1:1 1:n
Jolg42 Jul 20, 2022
a8fcb62
1:1 test all referral actions for onDelete & clean
Jolg42 Jul 20, 2022
6354160
chore: improved ref actions, fixed failing tests
jkomyno Jul 20, 2022
06ed9dd
Merge branch 'joel/referential-integrity' of https://github.com/prism…
jkomyno Jul 20, 2022
a9a15b1
chore: reproduced issue #14271
jkomyno Jul 21, 2022
4c6fc48
chore: split relationships in separate files
jkomyno Jul 21, 2022
6ae6a66
split m:n mongodb tests into its own file
Jolg42 Jul 22, 2022
4803cad
add `enabled Boolean?` on 1-to-n
Jolg42 Jul 26, 2022
29550e2
m:n add comments where RI=prisma - Cascade resolves instead of failin…
Jolg42 Jul 26, 2022
915f7b6
add `published Boolean?` to MongoDB and update tests
Jolg42 Jul 26, 2022
1988358
1:1 add `enabled Boolean?` and MongoDB update tests
Jolg42 Jul 26, 2022
eecc9a3
add `published Boolean?` to m:n with update tests
Jolg42 Jul 26, 2022
793c021
chore: updated sql server tests
jkomyno Jul 26, 2022
f94489e
Merge branch 'joel/referential-integrity' of https://github.com/prism…
jkomyno Jul 26, 2022
5c4fc12
add comments to m:n
Jolg42 Jul 27, 2022
da94f53
add a mongodb test for immutable _id
Jolg42 Aug 1, 2022
2d51b76
full database matrix for CI
Jolg42 Aug 1, 2022
829a6cd
split schemas into simple files
Jolg42 Aug 1, 2022
1b270af
m to n MongoDB: change tests to match current implementation expectat…
Jolg42 Aug 1, 2022
5086251
chore: add JSON support to getTestSuiteFullName
jkomyno Aug 1, 2022
94cc536
chore: moved ref integrity utils to its own folder. Added builder pat…
jkomyno Aug 1, 2022
6e8acc9
chore: added sqlite support and referentialIntegrity=prisma snapshots…
jkomyno Aug 1, 2022
3367c92
chore: pnpm-lock
jkomyno Aug 1, 2022
0024f61
chore: merge upstream
jkomyno Aug 1, 2022
1a3a59f
chore: removed temp folder that wasn't supposed to be committed
jkomyno Aug 3, 2022
162915f
chore: imported right 'checkIfEmpty' util for m:n relation
jkomyno Aug 3, 2022
cab95b6
clean and add sqlite on m to n
Jolg42 Aug 2, 2022
059b400
m to n add RI=Prisma messages as comments + small edits
Jolg42 Aug 2, 2022
ebadbd6
m:n: split 1 test for prisma/foreignKeys
Jolg42 Aug 2, 2022
441fb2b
chore: added prisma snapshots and errors as comments in m:n relation …
jkomyno Aug 3, 2022
aaad48e
chore: added mongodb and comments to _matrix
jkomyno Aug 3, 2022
f86cd25
fix: moved _referential-integrity-utils to _utils/referential-integri…
jkomyno Aug 3, 2022
76726c2
update matrix for MongoDB: add SetNull
Jolg42 Aug 3, 2022
8810f20
chore: added comments to m:n
jkomyno Aug 3, 2022
64992b0
m to n: small edits for RI=prisma
Jolg42 Aug 3, 2022
4e035e9
test 1:1 / 1:n add expects for expected throws and fix some RI=prisma…
Jolg42 Aug 3, 2022
872de6b
chore: prettier
Jolg42 Aug 3, 2022
d6803cc
1:1 handle error messages depending on RI=prisma/foreignKeys
Jolg42 Aug 3, 2022
3247e70
* simplify conditionals
Jolg42 Aug 3, 2022
022698a
m to n: change expectations to match current state
Jolg42 Aug 3, 2022
c9ab75b
chore: comment skipped test
Jolg42 Aug 3, 2022
dfc0ad7
sqlite: skip createMany in 1:n relations
jkomyno Aug 3, 2022
cd9e597
chore: added missing sqlite snapshots to 1:n relation
jkomyno Aug 4, 2022
b0dfc6b
1:n add missing delete action variants
Jolg42 Aug 4, 2022
04fae89
1:n simplify and handle expected RI=prisma tests that should succeed
Jolg42 Aug 4, 2022
49efaf6
chore: added reproduction of issue #10000
jkomyno Aug 5, 2022
0787fba
chore: updated reproduction of issue #10000
jkomyno Aug 8, 2022
a09989e
chore: reproduce issue #12378
jkomyno Aug 8, 2022
f256728
Merge remote-tracking branch 'origin' into joel/referential-integrity
Jolg42 Aug 8, 2022
5344f8a
1:1 separate onUpdate: Restrict, NoAction
Jolg42 Aug 8, 2022
dbdea34
1:1 fix create test from should throw to should succeed
Jolg42 Aug 8, 2022
c01beb9
Merge remote-tracking branch 'origin/main' into joel/referential-inte…
Jolg42 Aug 9, 2022
5fa5397
ci: separate action test for each relation / file
Jolg42 Aug 9, 2022
9dbef31
ci: continue-on-error: true
Jolg42 Aug 9, 2022
80b7928
fix: referential actions test params
Jolg42 Aug 9, 2022
19a434d
fix ts checks
Jolg42 Aug 9, 2022
81f3b32
only run pnpm run test:functional:code filename
Jolg42 Aug 9, 2022
41f1bbf
fix Cannot destructure property 'onDelete' of 'suiteConfig.referentia…
Jolg42 Aug 9, 2022
36ebccf
chore: added reproduction of issue #12557
jkomyno Aug 9, 2022
6efc102
Merge branch 'joel/referential-integrity' of github.com:prisma/prisma…
jkomyno Aug 9, 2022
cbb5011
chore: add assertions to nested child connect in 1:1
jkomyno Aug 9, 2022
631b8ee
chore: clean unused code and better describe title
Jolg42 Aug 11, 2022
1fdadeb
Merge branch 'joel/referential-integrity' of github.com:prisma/prisma…
Jolg42 Aug 11, 2022
e48b682
Merge remote-tracking branch 'origin' into joel/referential-integrity
Jolg42 Aug 25, 2022
664bc2f
test: add test about NO ACTION behavior with DEFERRABLE constraint
Jolg42 Aug 25, 2022
ae0a082
chore: merge main, fix conflicts
jkomyno Sep 29, 2022
2d4356c
Merge remote-tracking branch 'origin' into joel/referential-integrity
Jolg42 Oct 4, 2022
3e181be
manually bump engines
Jolg42 Oct 5, 2022
7a8fb1a
chore: rename referentialIntegrity datasource property to relationMode
Jolg42 Oct 5, 2022
c09fe8c
Merge remote-tracking branch 'origin' into joel/referential-integrity
Jolg42 Oct 5, 2022
1c6e3f6
fix github actions
Jolg42 Oct 5, 2022
c4d074c
fix test about 14759 and RELATION_MODE env var
Jolg42 Oct 5, 2022
e492e01
Merge branch 'main' into joel/referential-integrity
Jolg42 Oct 5, 2022
c261132
cleanup some reproduce-x test cases
Jolg42 Oct 5, 2022
3682d93
add sqlite error snapshot
Jolg42 Oct 6, 2022
9f71b91
remove continue-on-error
Jolg42 Oct 6, 2022
3c3753d
remove outdated comments
Jolg42 Oct 6, 2022
5a3373c
Merge remote-tracking branch 'origin' into joel/referential-integrity
Jolg42 Oct 6, 2022
cde0d74
ci: remove last continue-on-error: true
Jolg42 Oct 6, 2022
fa554a3
test: add `SetNull` to the matrix only for relationMode=prisma
Jolg42 Oct 7, 2022
9bf74c3
ci: add continue-on-error: true to run all tests
Jolg42 Oct 7, 2022
fdb1604
fix snapshot with lowerace table name and run SQL Server
Jolg42 Oct 7, 2022
8d71cfe
exclude SQL Server / SetNull when relationMode !== prisma
Jolg42 Oct 7, 2022
9f93563
fix computeMatrix for SQL Server Restrict emulation which is not impl…
Jolg42 Oct 7, 2022
f6014a6
change failing tests (issue 15683) to use .failing
Jolg42 Oct 7, 2022
db685f8
fix SQL Server test
Jolg42 Oct 7, 2022
4d0c812
test(reproductions): fix empty test name
Jolg42 Oct 11, 2022
f5ce3fb
fix relationMode = prisma SQL Server error snapshot
Jolg42 Oct 11, 2022
1ba83a3
fix relationMode = prisma SQL Server error snapshot
Jolg42 Oct 11, 2022
6f271c0
fix relationMode = prisma SQL Server error snapshot
Jolg42 Oct 11, 2022
124f30d
Merge branch 'main' into joel/referential-integrity
Jolg42 Oct 11, 2022
0c5622e
comment vitess docker image (unused) and put back timeout to 60s
Jolg42 Oct 11, 2022
dd84c3b
test: fix snapshots for field-reference
Jolg42 Oct 11, 2022
4ce0347
test: fix snapshot and getTestSuiteParametersString
Jolg42 Oct 11, 2022
444a2e9
ignore expected type errors
Jolg42 Oct 11, 2022
7190f07
add note about SetNull is not run for foreignKeys in the test suite
Jolg42 Oct 11, 2022
bfdf450
test: tweak comment and fix 1:1 test snapshots
Jolg42 Oct 11, 2022
fa5684a
Unused '@ts-expect-error' directive.
Jolg42 Oct 11, 2022
7bf7b1d
add `--relation-mode-tests-only` to unblock merge
Jolg42 Oct 11, 2022
72c2952
Merge branch 'main' into joel/referential-integrity
Jolg42 Oct 11, 2022
b1b35c6
Merge remote-tracking branch 'origin' into joel/referential-integrity
Jolg42 Oct 12, 2022
1c6f5bd
test: skip NoAction for PostgreSQL and SQLite
Jolg42 Oct 12, 2022
b1e1463
fix relationMode value
Jolg42 Oct 12, 2022
172ec1c
fix test name + comments
Jolg42 Oct 12, 2022
81ab764
cleanup matrix and move reproduce tests to issues directory
Jolg42 Oct 12, 2022
1aca963
add test for referentialIntegrity="prisma"
Jolg42 Oct 12, 2022
4731c03
cleanup comments and misleading `toThrowError()` for expected to fail…
Jolg42 Oct 12, 2022
550d08a
chore: removed useless comment
jkomyno Oct 12, 2022
8bf7e2b
chore: removed useless comments
jkomyno Oct 12, 2022
009f294
fix imports for moved tests in issues directory
Jolg42 Oct 12, 2022
698edfc
update README [skip ci]
Jolg42 Oct 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
749 changes: 17 additions & 732 deletions .github/workflows/test.yml

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,57 @@ services:
ports:
- '26257:26257'

# Planetscale
# From https://github.com/prisma/prisma-engines/blob/976a00ae3c30ab9507fa742986c9c6f5327ba10f/docker-compose.yml

# vitess-test-5_7:
# image: vitess/vttestserver:mysql57@sha256:2b132a22d08b3b227d9391f8f58ed7ab5c081ca07bf0f87a0c166729124d360a
# restart: always
# ports:
# - 33577:33577
# environment:
# PORT: 33574
# KEYSPACES: "test"
# NUM_SHARDS: "1"
# MYSQL_BIND_HOST: "0.0.0.0"
# FOREIGN_KEY_MODE: "disallow"

vitess-test-8_0:
image: vitess/vttestserver:mysql80@sha256:9412e3d51bde38e09c3039090b5c68808e299579f12c79178a4ec316f7831889
restart: always
ports:
- 33807:33807
environment:
PORT: 33804
KEYSPACES: 'test'
NUM_SHARDS: '1'
MYSQL_BIND_HOST: '0.0.0.0'
FOREIGN_KEY_MODE: 'disallow'

# vitess-shadow-5_7:
# image: vitess/vttestserver:mysql57@sha256:2b132a22d08b3b227d9391f8f58ed7ab5c081ca07bf0f87a0c166729124d360a
# restart: always
# ports:
# - 33578:33577
# environment:
# PORT: 33574
# KEYSPACES: "shadow"
# NUM_SHARDS: "1"
# MYSQL_BIND_HOST: "0.0.0.0"
# FOREIGN_KEY_MODE: "disallow"
#
# vitess-shadow-8_0:
# image: vitess/vttestserver:mysql80@sha256:9412e3d51bde38e09c3039090b5c68808e299579f12c79178a4ec316f7831889
# restart: always
# ports:
# - 33808:33807
# environment:
# PORT: 33804
# KEYSPACES: 'shadow'
# NUM_SHARDS: '1'
# MYSQL_BIND_HOST: '0.0.0.0'
# FOREIGN_KEY_MODE: 'disallow'

mysql:
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password --lower_case_table_names=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { merge } from '../../../../../helpers/blaze/merge'
import { MatrixTestHelper } from './defineMatrix'
import type { TestSuiteMeta } from './setupTestSuiteMatrix'

export type TestSuiteMatrix = { [K in string]: string }[][]
export type TestSuiteMatrix = { [K in string]: string | Record<string, string> }[][]
export type TestSuiteConfig = ReturnType<typeof getTestSuiteConfigs>[number]

type MatrixModule = (() => TestSuiteMatrix) | MatrixTestHelper<TestSuiteMatrix>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/tests/functional/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = () => {
globalSetup: './_utils/globalSetup.js',
snapshotSerializers: ['@prisma/internals/src/utils/jestSnapshotSerializer'],
setupFilesAfterEnv: ['./_utils/setupFilesAfterEnv.ts'],
testTimeout: 40000,
testTimeout: 10_000,
Jolg42 marked this conversation as resolved.
Show resolved Hide resolved
collectCoverage: process.env.CI ? true : false,
}

Expand Down
121 changes: 121 additions & 0 deletions packages/client/tests/functional/referential-integrity/_matrix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { defineMatrix } from '../_utils/defineMatrix'
import { Providers } from '../_utils/providers'

const RI = process.env.RI
if (RI && RI !== 'prisma' && RI !== 'foreignKeys') {
throw new Error(`RI must be either "prisma" or "foreignKeys" but was "${RI}"`)
}

type RIType = 'prisma' | 'foreignKeys' | ''
const referentialIntegrity: RIType = (RI as RIType) || ''

// Note: testing 'SetDefault' requires a relation with a scalar field having the "@default" attribute.
// If no defaults are provided for any of the scalar fields, a runtime error will be thrown.
//
// Note: 'Restrict' is not available when using 'sqlserver' as a provider, and it triggers a schema parsing error arising from DMMF.
//
// Note: 'SetNull' is only available on optional relations.
//
// Note: 'SetDefault' is making SQL Server crash badly
// const referentialActionsChoices = ['', 'Cascade', 'NoAction']

// TODO: generate the referentialActions combinations matrix outside, and merge it to the defined matrix below
type ReferentialActions = 'DEFAULT' | 'Cascade' | 'Restrict' | 'NoAction' | 'SetNull' | 'SetDefault'

/**
* [foreignKeys] Tests with referential actions that are passing on Postgres, CockroachDB, MySQL, and SQL Server:
* - [x] DEFAULT
* - [x] Cascade
* - [x] NoAction
*
* SetNull causes Rust panics on MySQL, and SQL Server.
* On CockroachDB, it causes jest to to timeout.
* On Postgres, it runs fine.
*
* SetDefault causes Rust panics on SQL Server.
* On CockroachDB, it causes jest to to timeout.
* On Postgres and MySQL, it runs fine.
*/

const onUpdate: ReferentialActions | string = 'DEFAULT'
const onDelete: ReferentialActions | string = 'DEFAULT'
// const onUpdate: ReferentialActions | string = 'Cascade'
// const onDelete: ReferentialActions | string = 'Cascade'
// const onUpdate: ReferentialActions | string = 'Restrict'
// const onDelete: ReferentialActions | string = 'Restrict'
// const onUpdate: ReferentialActions | string = 'NoAction'
// const onDelete: ReferentialActions | string = 'NoAction'
// const onUpdate: ReferentialActions | string = 'SetNull'
// const onDelete: ReferentialActions | string = 'SetNull'
// const onUpdate: ReferentialActions | string = 'SetDefault'
// const onDelete: ReferentialActions | string = 'SetDefault'

// figure out how to separate the test

// TODO: fix mysql issues with Restrict
export default defineMatrix(() => [
[
{
provider: Providers.POSTGRESQL,
id: 'String @id',
referentialIntegrity,
referentialActions: {
onUpdate,
onDelete,
},
},
{
provider: Providers.COCKROACHDB,
id: 'String @id',
referentialIntegrity,
referentialActions: {
onUpdate,
onDelete,
},
},
{
provider: Providers.MYSQL,
id: 'String @id',
referentialIntegrity,
referentialActions: {
onUpdate,
onDelete,
},
},
{
provider: Providers.SQLSERVER,
id: 'String @id',
referentialIntegrity,
referentialActions: {
// Restrict is not supported by SQL Server
// TODO we should not run the test intead of switching to default
onUpdate: onUpdate === 'Restrict' ? '' : onUpdate,
onDelete: onDelete === 'Restrict' ? '' : onDelete,
},
},
{
provider: Providers.SQLITE,
id: 'String @id',
referentialIntegrity,
referentialActions: {
onUpdate,
onDelete,
},
},
{
provider: Providers.MONGODB,
id: 'String @id @map("_id")',
referentialIntegrity,
referentialActions: {
// Note: on MongoDB SetDefault is not supported
onUpdate: onUpdate === 'SetDefault' ? '' : onUpdate,
onDelete: onDelete === 'SetDefault' ? '' : onDelete,
},
},
],
[
{
previewFeatures: '"referentialIntegrity"',
},
],
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @ts-ignore this is just for type checks
declare let prisma: import('@prisma/client').PrismaClient

export async function checkIfEmpty(...models: unknown[]) {
const checkEmptyArr = await prisma.$transaction(models.map((model) => prisma[model].findMany()))
checkEmptyArr.forEach((checkEmpty) => {
expect(checkEmpty).toHaveLength(0)
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { Providers } from '../../_utils/providers'
import testMatrix from '../_matrix'

const PLANETSCALE = false
// const PLANETSCALE = true

export default testMatrix.setupSchema(({ provider, previewFeatures, referentialIntegrity, referentialActions, id }) => {
// if referentialIntegrity is not defined, we do not add the line
// if referentialIntegrity is defined
// we add the line only if the provider is not MongoDB, since MongoDB doesn't need the setting, it's on by default
const referentialIntegrityLine =
provider === Providers.MONGODB || !referentialIntegrity ? '' : `referentialIntegrity = "${referentialIntegrity}"`

const schemaHeader = /* Prisma */ `
generator client {
provider = "prisma-client-js"
previewFeatures = [${previewFeatures}]
}

datasource db {
provider = "${provider}"
${
PLANETSCALE && provider === Providers.MYSQL
? `url = "mysql://root:root@127.0.0.1:33807/PRISMA_DB_NAME"`
: `url = env("DATABASE_URI_${provider}")`
}
${referentialIntegrityLine}
}
`

let referentialActionLine = ''
if (referentialActions.onUpdate && referentialActions.onUpdate !== 'DEFAULT') {
referentialActionLine += `, onUpdate: ${referentialActions.onUpdate}`
}
if (referentialActions.onDelete && referentialActions.onDelete !== 'DEFAULT') {
referentialActionLine += `, onDelete: ${referentialActions.onDelete}`
}

const manyToManySQLExplicit = /* Prisma */ `
model PostManyToMany {
id ${id}
categories CategoriesOnPostsManyToMany[]
published Boolean?
}

model CategoryManyToMany {
id ${id}
posts CategoriesOnPostsManyToMany[]
published Boolean?
}

model CategoriesOnPostsManyToMany {
post PostManyToMany @relation(fields: [postId], references: [id]${referentialActionLine})
postId String
category CategoryManyToMany @relation(fields: [categoryId], references: [id]${referentialActionLine})
categoryId String

@@id([postId, categoryId])
}
`

const manyToManySQLImplicit = /* Prisma */ `
model PostManyToMany {
id String @id
categories CategoryManyToMany[]
published Boolean?
}

model CategoryManyToMany {
id String @id
posts PostManyToMany[]
published Boolean?
}
`

const manyToManyMongoDB = /* Prisma */ `
model PostManyToMany {
id String @id @map("_id")
categoryIDs String[]
categories CategoryManyToMany[] @relation(fields: [categoryIDs], references: [id])
published Boolean?
}

model CategoryManyToMany {
id String @id @map("_id")
postIDs String[]
posts PostManyToMany[] @relation(fields: [postIDs], references: [id])
published Boolean?
}
`

return /* Prisma */ `
${schemaHeader}

//
// 1:1 relation
//
model UserOneToOne {
id ${id}
profile ProfileOneToOne?
enabled Boolean?
}
model ProfileOneToOne {
id ${id}
user UserOneToOne @relation(fields: [userId], references: [id]${referentialActionLine})
userId String @unique
enabled Boolean?
}

//
// 1:n relation
//
model UserOneToMany {
id ${id}
posts PostOneToMany[]
enabled Boolean?
}
model PostOneToMany {
id ${id}
author UserOneToMany @relation(fields: [authorId], references: [id]${referentialActionLine})
authorId String
}

//
// m:n relation
//
${provider === Providers.MONGODB ? manyToManyMongoDB : manyToManySQLExplicit}
`
})