添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
伤情的核桃
·
马斯洛需求层次理论与购买动机 - ...
·
1 月前
·
宽容的野马
·
c语言中如何让一个语句只执行一次 | ...
·
2 月前
·
高大的苹果
·
[SOLVED] opencv / AUR ...
·
3 月前
·
私奔的登山鞋
·
Issue 45285: c_char ...
·
4 月前
·
温暖的遥控器
·
springboot ...
·
6 月前
·
link管理
›
Referential actions
post
prisma
https://www.prisma.io/docs/concepts/components/prisma-schema/relations/referential-actions
爱搭讪的长颈鹿
1 年前
</noscript><div id="___gatsby"><div style="outline:none" tabindex="-1" id="gatsby-focus-wrapper"><div class="layout__BannerWrapper-sc-bupt9j-6 gzeUNt"><div class="sc-eKszNL hGlrpf"><div class="sc-olbas dDGcRa"><a href="/data-platform/accelerate" class="banner-url">Up to 1000x faster database queries with <b>Accelerate</b> <!-- -->-><!-- --> <u>Sign up for Early Access</u></a></div></div></div><div class="header__HeaderWrapper-sc-1w16195-0 egaely"><div class="header__Container-sc-1w16195-1 cODcuA"><div class="sc-ivTmOn dFUqCc"><div class="sc-gsnTZi kOJsJZ container"><div class="sc-dIouRR kabXXY"><div class="sc-bBrHrO clkNpY"><a href="https://www.prisma.io"><img src="https://prismalens.vercel.app/header/logo-white.svg" width="90" height="27" alt="prisma_logo" style="cursor:pointer;display:block"/></a><button type="primary" color="indigo" class="sc-hKMtZM jDkVzN menu-toggle-button"><svg name="menu" lens-role="icon" width="24" height="24" class="flex-grow-0 flex-shrink-0" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="/feather-icons.svg#menu"/></svg></button></div><div class="sc-hHLeRK ebdRSF hidden-on-mobile"><div class="item"><a class="sc-dmRaPn sc-kgflAQ hDMqQd jjqviM has-dropdown">Product<svg name="chevron-down" lens-role="icon" width="24" height="24" class="flex-grow-0 flex-shrink-0 item-chevron" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="/feather-icons.svg#chevron-down"/></svg></a><div class="panel-outer undefined"><div class="panel-inner"><div class="panel-spacer"><div class="sc-ftvSup bHEHJn"><h4 class="sc-papXJ sc-jqUVSM drLJT dmZIVd">Prisma ORM</h4><a color="indigo" href="/client" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="terminal" class="svg-inline--fa fa-terminal sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 576 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M6.338 72.25C-2.637 62.5-2.004 47.31 7.751 38.34C17.51 29.36 32.69 29.1 41.66 39.75L225.7 239.8C234.1 248.9 234.1 263.1 225.7 272.2L41.66 472.2C32.69 482 17.51 482.6 7.751 473.7C-2.004 464.7-2.636 449.5 6.338 439.8L175.4 256L6.338 72.25zM552 432C565.3 432 576 442.7 576 456C576 469.3 565.3 480 552 480H248C234.7 480 224 469.3 224 456C224 442.7 234.7 432 248 432H552z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Client</div><div class="link-subtitle">Write Queries the way you think</div></div></a><a color="indigo" href="/migrate" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="arrows-rotate" class="svg-inline--fa fa-arrows-rotate sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M454.7 288.1c-12.78-3.75-26.06 3.594-29.75 16.31C403.3 379.9 333.8 432 255.1 432c-66.53 0-126.8-38.28-156.5-96h100.4c13.25 0 24-10.75 24-24S213.2 288 199.9 288h-160c-13.25 0-24 10.75-24 24v160c0 13.25 10.75 24 24 24s24-10.75 24-24v-102.1C103.7 436.4 176.1 480 255.1 480c99 0 187.4-66.31 215.1-161.3C474.8 305.1 467.4 292.7 454.7 288.1zM472 16C458.8 16 448 26.75 448 40v102.1C408.3 75.55 335.8 32 256 32C157 32 68.53 98.31 40.91 193.3C37.19 206 44.5 219.3 57.22 223c12.84 3.781 26.09-3.625 29.75-16.31C108.7 132.1 178.2 80 256 80c66.53 0 126.8 38.28 156.5 96H312C298.8 176 288 186.8 288 200S298.8 224 312 224h160c13.25 0 24-10.75 24-24v-160C496 26.75 485.3 16 472 16z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Migrate</div><div class="link-subtitle">Generate customisable SQL migrations</div></div></a><h4 class="sc-papXJ sc-jqUVSM drLJT dmZIVd">Prisma Data Platform</h4><a color="indigo" href="/data-platform/accelerate" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="bolt" class="svg-inline--fa fa-bolt sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 384 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M289.7 .0006C308.8 .0006 322.6 18.26 317.4 36.61L263.8 224H349.1C368.4 224 384 239.6 384 258.9C384 269.2 379.5 278.9 371.7 285.6L112.9 505.2C107.7 509.6 101.1 512 94.27 512C75.18 512 61.4 493.7 66.64 475.4L120.2 288H33.74C15.1 288 0 272.9 0 254.3C0 244.4 4.315 235 11.81 228.6L271.1 6.893C276.3 2.445 282.9 0 289.7 0V.0006zM253.6 84.99L72.36 240H152C159.5 240 166.6 243.5 171.2 249.5C175.7 255.6 177.1 263.4 175.1 270.6L130.3 427.5L313.5 272H232C224.5 272 217.4 268.5 212.8 262.5C208.3 256.4 206.9 248.6 208.9 241.4L253.6 84.99z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title"><div class="link-title-label">Accelerate<span class="label">early access</span></div></div><div class="link-subtitle">Query up to 1000x faster</div></div></a><a color="indigo" href="/data-platform" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="folder-magnifying-glass" class="svg-inline--fa fa-folder-magnifying-glass sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M448 96h-172.1L226.7 50.75C214.7 38.74 198.5 32 181.5 32H64C28.65 32 0 60.66 0 96v320c0 35.34 28.65 64 64 64h384c35.35 0 64-28.66 64-64V160C512 124.7 483.3 96 448 96zM464 416c0 8.824-7.178 16-16 16H64c-8.822 0-16-7.176-16-16V96c0-8.824 7.178-16 16-16h117.5c4.273 0 8.293 1.664 11.31 4.688L256 144h192c8.822 0 16 7.176 16 16V416zM322.4 320.5C330.8 306.2 336 289.8 336 272c0-53.02-42.98-96-96-96s-96 42.98-96 96s42.98 96 96 96c17.77 0 34.21-5.16 48.48-13.58l46.55 46.55C339.7 405.7 345.8 408 352 408s12.28-2.344 16.97-7.031c9.375-9.375 9.375-24.56 0-33.94L322.4 320.5zM240 320C213.5 320 192 298.5 192 272S213.5 224 240 224S288 245.5 288 272S266.5 320 240 320z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Data Browser</div><div class="link-subtitle">Explore and manipulate data in your projects</div></div></a><a color="indigo" href="/data-platform/proxy" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="server" class="svg-inline--fa fa-server sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M448 32H64C28.65 32 0 60.65 0 96v64c0 35.35 28.65 64 64 64h384c35.35 0 64-28.65 64-64V96C512 60.65 483.3 32 448 32zM464 160c0 8.822-7.178 16-16 16H64C55.18 176 48 168.8 48 160V96c0-8.822 7.178-16 16-16h384c8.822 0 16 7.178 16 16V160zM448 288H64c-35.35 0-64 28.65-64 64v64c0 35.35 28.65 64 64 64h384c35.35 0 64-28.65 64-64v-64C512 316.7 483.3 288 448 288zM464 416c0 8.822-7.178 16-16 16H64c-8.822 0-16-7.178-16-16v-64c0-8.822 7.178-16 16-16h384c8.822 0 16 7.178 16 16V416zM352 104c-13.25 0-24 10.74-24 24c0 13.25 10.75 24 24 24S376 141.3 376 128C376 114.7 365.3 104 352 104zM416 104c-13.25 0-24 10.74-24 24c0 13.25 10.75 24 24 24S440 141.3 440 128C440 114.7 429.3 104 416 104zM352 360c-13.25 0-24 10.74-24 24c0 13.25 10.75 24 24 24s24-10.75 24-24C376 370.7 365.3 360 352 360zM416 360c-13.25 0-24 10.74-24 24c0 13.25 10.75 24 24 24s24-10.75 24-24C440 370.7 429.3 360 416 360z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Data Proxy</div><div class="link-subtitle">Manage and scale your connection pool</div></div></a></div></div></div></div></div><div class="item"><a href="/docs" class="sc-dmRaPn sc-kgflAQ hDMqQd jjqviM light">Docs</a></div><div class="item"><a class="sc-dmRaPn sc-kgflAQ hDMqQd jjqviM has-dropdown">Developer<svg name="chevron-down" lens-role="icon" width="24" height="24" class="flex-grow-0 flex-shrink-0 item-chevron" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="/feather-icons.svg#chevron-down"/></svg></a><div class="panel-outer undefined"><div class="panel-inner"><div class="panel-spacer"><div width="870" class="sc-ftvSup fHYHNd"><div class="developer-dropdown-container"><a color="indigo" href="/docs/getting-started" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-line-up" class="svg-inline--fa fa-chart-line-up sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M48 408C48 421.3 58.75 432 72 432H488C501.3 432 512 442.7 512 456C512 469.3 501.3 480 488 480H72C32.24 480 0 447.8 0 408V56C0 42.75 10.75 32 24 32C37.25 32 48 42.75 48 56V408zM344 128H456C469.3 128 480 138.7 480 152V264C480 277.3 469.3 288 456 288C442.7 288 432 277.3 432 264V209.9L320.1 320.1C311.6 330.3 296.4 330.3 287 320.1L207.1 241.9L144.1 304.1C135.6 314.3 120.4 314.3 111 304.1C101.7 295.6 101.7 280.4 111 271L191 191C200.4 181.7 215.6 181.7 224.1 191L304 270.1L398.1 176H344C330.7 176 320 165.3 320 152C320 138.7 330.7 128 344 128V128z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Get Started</div></div></a><a color="indigo" href="/learn" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="book-open-cover" class="svg-inline--fa fa-book-open-cover sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 640 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M600.2 32.97L592 35.03v368.1L320 463.6l-272-60.45V35.03L39.76 32.97C19.56 27.92 0 43.19 0 64.01v351.1c0 15 10.42 27.98 25.06 31.24l288 63.1c4.572 1.016 9.311 1.016 13.88 0l288-63.1C629.6 443.1 640 431 640 416V64.01C640 43.19 620.4 27.92 600.2 32.97zM97.97 375.2l216 56C315.9 431.8 317.1 432 320 432s4.062-.25 6.031-.7813l216-56C552.6 372.5 560 362.9 560 352V24c0-7.125-3.156-13.91-8.656-18.44c-5.5-4.562-12.66-6.469-19.72-5.156L320 39.59L108.4 .4062C101.3-.9062 94.16 1 88.66 5.562C83.16 10.09 80 16.88 80 24V352C80 362.9 87.41 372.5 97.97 375.2zM344 83.96L512 52.84v280.6l-168 43.56V83.96zM128 52.84l168 31.12v293L128 333.4V52.84z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Tutorials</div></div></a><a color="indigo" href="https://playground.prisma.io" class="sc-breuTD MGqAB"><div class="link-icon"/><div><div class="sc-ksZaOG bAtKBi link-title">Playground</div></div></a><a color="indigo" href="https://github.com/prisma/prisma-examples" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="grid-2" class="svg-inline--fa fa-grid-2 sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 448 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M0 80C0 53.49 21.49 32 48 32H144C170.5 32 192 53.49 192 80V176C192 202.5 170.5 224 144 224H48C21.49 224 0 202.5 0 176V80zM48 176H144V80H48V176zM0 336C0 309.5 21.49 288 48 288H144C170.5 288 192 309.5 192 336V432C192 458.5 170.5 480 144 480H48C21.49 480 0 458.5 0 432V336zM48 432H144V336H48V432zM400 32C426.5 32 448 53.49 448 80V176C448 202.5 426.5 224 400 224H304C277.5 224 256 202.5 256 176V80C256 53.49 277.5 32 304 32H400zM400 80H304V176H400V80zM256 336C256 309.5 277.5 288 304 288H400C426.5 288 448 309.5 448 336V432C448 458.5 426.5 480 400 480H304C277.5 480 256 458.5 256 432V336zM304 432H400V336H304V432z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Prisma Examples<svg fill="none" stroke="currentColor" stroke-width="2.5" width="18" height="18" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="/feather-icons.svg#arrow-up-right"/></svg></div></div></a><a color="indigo" href="/stack" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="layer-group" class="svg-inline--fa fa-layer-group sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M231.2 5.092C239 1.732 247.5 0 256 0C264.5 0 272.1 1.732 280.8 5.092L490.1 94.79C503.4 100.5 512 113.5 512 128C512 142.5 503.4 155.5 490.1 161.2L280.8 250.9C272.1 254.3 264.5 256 256 256C247.5 256 239 254.3 231.2 250.9L21.9 161.2C8.614 155.5 0 142.5 0 128C0 113.5 8.614 100.5 21.9 94.79L231.2 5.092zM256 48C253.1 48 251.1 48.41 250.1 49.21L66.26 128L250.1 206.8C251.1 207.6 253.1 208 256 208C258 208 260 207.6 261.9 206.8L445.7 128L261.9 49.21C260 48.41 258 48 256 48V48zM250.1 334.8C251.1 335.6 253.1 336 256 336C258 336 260 335.6 261.9 334.8L452 253.3C447.4 246.4 446.5 237.2 450.5 229.3C456.5 217.4 470.9 212.6 482.7 218.5L491.8 223.1C504.2 229.3 512 241.9 512 255.7C512 270.4 503.3 283.6 489.9 289.3L280.8 378.9C272.1 382.3 264.5 384 256 384C247.5 384 239 382.3 231.2 378.9L22.81 289.6C8.971 283.7 .0006 270.1 .0006 255C.0006 242.9 5.869 231.5 15.76 224.4L26.05 217C36.84 209.3 51.83 211.8 59.53 222.6C66.15 231.9 65.24 244.3 57.1 252.5L250.1 334.8zM59.53 350.6C66.15 359.9 65.24 372.3 57.1 380.5L250.1 462.8C251.1 463.6 253.1 464 256 464C258 464 260 463.6 261.9 462.8L452 381.3C447.4 374.4 446.5 365.2 450.5 357.3C456.5 345.4 470.9 340.6 482.7 346.5L491.8 351.1C504.2 357.3 512 369.9 512 383.7C512 398.4 503.3 411.6 489.9 417.3L280.8 506.9C272.1 510.3 264.5 512 256 512C247.5 512 239 510.3 231.2 506.9L22.81 417.6C8.971 411.7 .001 398.1 .001 383C.001 370.9 5.87 359.5 15.76 352.4L26.05 345C36.84 337.3 51.83 339.8 59.53 350.6L59.53 350.6z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Prisma in your Stack</div></div></a><a color="indigo" href="/support" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="headset" class="svg-inline--fa fa-headset sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M256 0C112.9 0 4.583 119.1 .0208 256L0 309.2C0 350.5 32.75 384 73.14 384h18.29C111.6 384 128 367.3 128 346.6V213.4C128 192.7 111.6 176 91.43 176H73.14c-3.277 0-6.344 .7148-9.498 1.148C94.8 101.5 169.3 48.2 256 48.19c86.74 .0117 161.2 53.36 192.4 128.1C445.2 176.7 442.1 176 438.9 176h-18.29C400.4 176 384 192.7 384 213.4v133.2C384 367.3 400.4 384 420.6 384h18.29c8.875 0 17.27-1.861 25.14-4.82V400c0 22.06-17.94 40-40 40h-110.7C305 425.7 289.7 416 272 416h-32C213.5 416 192 437.5 192 464S213.5 512 239.1 512H272c17.72 0 33.03-9.711 41.34-24H424c48.53 0 88-39.47 88-88V256C507.4 119.1 399.1 0 256 0zM73.14 224H80v112H73.14C59.28 336 48 323.1 48 309.2V256c0-2.41 .2793-4.75 .3613-7.141C49.33 235 59.91 224 73.14 224zM438.9 336H432V224h6.857c13.23 0 23.81 11.04 24.78 24.86C463.7 251.3 464 253.6 464 256v53.24C464 323.1 452.7 336 438.9 336z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Support</div></div></a><a color="indigo" href="/ecosystem" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="globe" class="svg-inline--fa fa-globe sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0zM256 464C263.4 464 282.1 456.8 303.6 415.6C312.4 397.9 319.1 376.4 325.6 352H186.4C192 376.4 199.6 397.9 208.4 415.6C229 456.8 248.6 464 256 464zM178.5 304H333.5C335.1 288.7 336 272.6 336 256C336 239.4 335.1 223.3 333.5 208H178.5C176.9 223.3 176 239.4 176 256C176 272.6 176.9 288.7 178.5 304V304zM325.6 160C319.1 135.6 312.4 114.1 303.6 96.45C282.1 55.22 263.4 48 256 48C248.6 48 229 55.22 208.4 96.45C199.6 114.1 192 135.6 186.4 160H325.6zM381.8 208C383.2 223.5 384 239.6 384 256C384 272.4 383.2 288.5 381.8 304H458.4C462.1 288.6 464 272.5 464 256C464 239.5 462.1 223.4 458.4 208H381.8zM342.1 66.61C356.2 92.26 367.4 124.1 374.7 160H440.6C419.2 118.9 384.4 85.88 342.1 66.61zM169.9 66.61C127.6 85.88 92.84 118.9 71.43 160H137.3C144.6 124.1 155.8 92.26 169.9 66.61V66.61zM48 256C48 272.5 49.93 288.6 53.57 304H130.2C128.8 288.5 128 272.4 128 256C128 239.6 128.8 223.5 130.2 208H53.57C49.93 223.4 48 239.5 48 256zM440.6 352H374.7C367.4 387.9 356.2 419.7 342.1 445.4C384.4 426.1 419.2 393.1 440.6 352zM137.3 352H71.43C92.84 393.1 127.6 426.1 169.9 445.4C155.8 419.7 144.6 387.9 137.3 352V352z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Ecosystem</div></div></a><a color="indigo" href="/community" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="comment" class="svg-inline--fa fa-comment sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M256 32C114.6 32 .0272 125.1 .0272 240c0 47.63 19.91 91.25 52.91 126.2c-14.88 39.5-45.87 72.88-46.37 73.25c-6.625 7-8.375 17.25-4.625 26C5.818 474.2 14.38 480 24 480c61.5 0 109.1-25.75 139.1-46.25C191.1 442.8 223.3 448 256 448c141.4 0 255.1-93.13 255.1-208S397.4 32 256 32zM256.1 400c-26.75 0-53.12-4.125-78.38-12.12l-22.75-7.125l-19.5 13.75c-14.25 10.12-33.88 21.38-57.5 29c7.375-12.12 14.37-25.75 19.88-40.25l10.62-28l-20.62-21.87C69.82 314.1 48.07 282.2 48.07 240c0-88.25 93.25-160 208-160s208 71.75 208 160S370.8 400 256.1 400z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Community</div></div></a><a color="indigo" href="/dataguide" class="sc-breuTD TlDZu"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="file-binary" class="svg-inline--fa fa-file-binary sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 384 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M365.3 93.38l-74.63-74.64C278.6 6.742 262.3 0 245.4 0H64C28.65 0 0 28.65 0 64l.0065 384c0 35.34 28.65 64 64 64H320c35.2 0 64-28.8 64-64V138.6C384 121.7 377.3 105.4 365.3 93.38zM336 448c0 8.836-7.164 16-16 16H64.02c-8.838 0-16-7.164-16-16L48 64.13c0-8.836 7.164-16 16-16h160L224 128c0 17.67 14.33 32 32 32h79.1V448zM216 264C216 277.3 226.8 288 240 288v80c-13.25 0-24 10.75-24 24S226.8 416 240 416H288c13.25 0 24-10.75 24-24S301.3 368 288 368V264c0-13.25-10.75-24-24-24H240C226.8 240 216 250.8 216 264zM144 240H128c-30.88 0-56 25.12-56 56v64C72 390.9 97.13 416 128 416h16c30.88 0 56-25.12 56-56v-64C200 265.1 174.9 240 144 240zM152 360c0 4.406-3.594 8-8 8H128c-4.406 0-8-3.594-8-8v-64C120 291.6 123.6 288 128 288h16c4.406 0 8 3.594 8 8V360z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Data Guide</div></div></a></div><a class="playground-item" href="https://playground.prisma.io" target="_blank"><div class="title"><img src="https://prismalens.vercel.app/header/prisma-logo.svg"/><span class="link-title">Prisma <br/>Playground</span></div><img src="https://prismalens.vercel.app/header/playground.svg" class="logo"/></a></div></div></div></div></div><div class="item"><a class="sc-dmRaPn sc-kgflAQ hDMqQd jjqviM has-dropdown">Use Cases<svg name="chevron-down" lens-role="icon" width="24" height="24" class="flex-grow-0 flex-shrink-0 item-chevron" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="/feather-icons.svg#chevron-down"/></svg></a><div class="panel-outer undefined"><div class="panel-inner"><div class="panel-spacer"><div width="441" class="sc-ftvSup fWRzcd"><a color="indigo" href="/showcase" class="sc-breuTD cFbHCg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="comment-quote" class="svg-inline--fa fa-comment-quote sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M168.2 384.9c-15-5.4-31.7-3.1-44.6 6.4c-8.2 6-22.3 14.8-39.4 22.7c5.6-14.7 9.9-31.3 11.3-49.4c1-12.9-3.3-25.7-11.8-35.5C60.4 302.8 48 272 48 240c0-79.5 83.3-160 208-160s208 80.5 208 160s-83.3 160-208 160c-31.6 0-61.3-5.5-87.8-15.1zM26.3 423.8c-1.6 2.7-3.3 5.4-5.1 8.1l-.3 .5c-1.6 2.3-3.2 4.6-4.8 6.9c-3.5 4.7-7.3 9.3-11.3 13.5c-4.6 4.6-5.9 11.4-3.4 17.4c2.5 6 8.3 9.9 14.8 9.9c5.1 0 10.2-.3 15.3-.8l.7-.1c4.4-.5 8.8-1.1 13.2-1.9c.8-.1 1.6-.3 2.4-.5c17.8-3.5 34.9-9.5 50.1-16.1c22.9-10 42.4-21.9 54.3-30.6c31.8 11.5 67 17.9 104.1 17.9c141.4 0 256-93.1 256-208S397.4 32 256 32S0 125.1 0 240c0 45.1 17.7 86.8 47.7 120.9c-1.9 24.5-11.4 46.3-21.4 62.9zM160 144c-17.7 0-32 14.3-32 32v48c0 17.7 14.3 32 32 32h32v7.3c0 11.7-8.5 21.7-20.1 23.7l-7.9 1.3c-13.1 2.2-21.9 14.5-19.7 27.6s14.5 21.9 27.6 19.7l7.9-1.3c34.7-5.8 60.2-35.8 60.2-71V224 200 176c0-17.7-14.3-32-32-32H160zm224 80V200 176c0-17.7-14.3-32-32-32H304c-17.7 0-32 14.3-32 32v48c0 17.7 14.3 32 32 32h32v7.3c0 11.7-8.5 21.7-20.1 23.7l-7.9 1.3c-13.1 2.2-21.9 14.5-19.7 27.6s14.5 21.9 27.6 19.7l7.9-1.3c34.7-5.8 60.2-35.8 60.2-71V224z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Customer Stories</div><div class="link-subtitle">Learn about applications built with Prisma</div></div></a><a color="indigo" href="/enterprise" class="sc-breuTD cFbHCg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-simple" class="svg-inline--fa fa-chart-simple sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 448 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M240 32C266.5 32 288 53.49 288 80V432C288 458.5 266.5 480 240 480H208C181.5 480 160 458.5 160 432V80C160 53.49 181.5 32 208 32H240zM240 80H208V432H240V80zM80 224C106.5 224 128 245.5 128 272V432C128 458.5 106.5 480 80 480H48C21.49 480 0 458.5 0 432V272C0 245.5 21.49 224 48 224H80zM80 272H48V432H80V272zM320 144C320 117.5 341.5 96 368 96H400C426.5 96 448 117.5 448 144V432C448 458.5 426.5 480 400 480H368C341.5 480 320 458.5 320 432V144zM368 432H400V144H368V432z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Enterprise</div><div class="link-subtitle">Up-level your applications with our Data Platform</div></div></a></div></div></div></div></div><div class="item"><a class="sc-dmRaPn sc-kgflAQ hDMqQd jjqviM has-dropdown">Company<svg name="chevron-down" lens-role="icon" width="24" height="24" class="flex-grow-0 flex-shrink-0 item-chevron" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="/feather-icons.svg#chevron-down"/></svg></a><div class="panel-outer undefined"><div class="panel-inner"><div class="panel-spacer"><div width="689" class="sc-ftvSup hmemjP"><div class="company-dropdown-container"><div class="company-links"><a color="indigo" href="/about" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="triangle" class="svg-inline--fa fa-triangle sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M256 32C270.2 32 283.3 39.52 290.5 51.75L506.5 419.8C513.8 432.1 513.8 447.4 506.7 459.9C499.6 472.3 486.3 480 472 480H40C25.66 480 12.41 472.3 5.287 459.9C-1.839 447.4-1.756 432.1 5.503 419.8L221.5 51.75C228.7 39.52 241.8 32 256 32V32zM256 87.8L53.97 432H458L256 87.8zM262.9 76.06C262.9 76.06 262.9 76.07 262.9 76.06V76.06zM262.9 76.06L256 72z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">About</div></div></a><a color="indigo" href="/blog" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="message-pen" class="svg-inline--fa fa-message-pen sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M325.7 117.3c-7.031-7.031-18.45-7.031-25.47 0l-18.23 18.23l48.01 48.01l18.24-18.24c7.029-7.035 7.029-18.44 0-25.47L325.7 117.3zM174.4 243.1C172.7 244.7 171.6 246.9 171.1 249.2l-9.521 47.61C160.8 301 164.5 304.7 168.7 303.9l47.61-9.52c2.322-.4687 4.455-1.609 6.131-3.281l90.58-90.57L264.1 152.5L174.4 243.1zM447.1 0h-384c-35.25 0-64 28.75-64 63.1v287.1c0 35.25 28.75 63.1 64 63.1h96v83.1c0 9.836 11.02 15.55 19.12 9.7l124.9-93.7h144c35.25 0 64-28.75 64-63.1V63.1C511.1 28.75 483.2 0 447.1 0zM464 352c0 8.75-7.25 16-16 16h-160l-80 60v-60H64c-8.75 0-16-7.25-16-16V64c0-8.75 7.25-16 16-16h384c8.75 0 16 7.25 16 16V352z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Blog</div></div></a><a color="indigo" href="/careers" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="chart-line-up" class="svg-inline--fa fa-chart-line-up sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M48 408C48 421.3 58.75 432 72 432H488C501.3 432 512 442.7 512 456C512 469.3 501.3 480 488 480H72C32.24 480 0 447.8 0 408V56C0 42.75 10.75 32 24 32C37.25 32 48 42.75 48 56V408zM344 128H456C469.3 128 480 138.7 480 152V264C480 277.3 469.3 288 456 288C442.7 288 432 277.3 432 264V209.9L320.1 320.1C311.6 330.3 296.4 330.3 287 320.1L207.1 241.9L144.1 304.1C135.6 314.3 120.4 314.3 111 304.1C101.7 295.6 101.7 280.4 111 271L191 191C200.4 181.7 215.6 181.7 224.1 191L304 270.1L398.1 176H344C330.7 176 320 165.3 320 152C320 138.7 330.7 128 344 128V128z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Careers</div></div></a><a color="indigo" href="/events" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="users-viewfinder" class="svg-inline--fa fa-users-viewfinder sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 640 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M48 136C48 149.3 37.25 160 24 160C10.75 160 0 149.3 0 136V32C0 14.33 14.33 0 32 0H136C149.3 0 160 10.75 160 24C160 37.25 149.3 48 136 48H48V136zM592 48H504C490.7 48 480 37.25 480 24C480 10.75 490.7 0 504 0H608C625.7 0 640 14.33 640 32V136C640 149.3 629.3 160 616 160C602.7 160 592 149.3 592 136V48zM160 488C160 501.3 149.3 512 136 512H32C14.33 512 0 497.7 0 480V376C0 362.7 10.75 352 24 352C37.25 352 48 362.7 48 376V464H136C149.3 464 160 474.7 160 488zM592 376C592 362.7 602.7 352 616 352C629.3 352 640 362.7 640 376V480C640 497.7 625.7 512 608 512H504C490.7 512 480 501.3 480 488C480 474.7 490.7 464 504 464H592V376zM268.4 290C274.7 288.7 281.3 288 288 288H352C358.7 288 365.3 288.7 371.6 290C372.7 290.2 373.8 290.5 374.9 290.7C398.5 296.5 418.7 311 431.8 330.6C432.1 332.4 434.1 334.2 435.2 336C443.3 350.1 448 366.5 448 384C448 401.7 433.7 416 416 416H224C206.3 416 192 401.7 192 384C192 366.5 196.7 350.1 204.8 336C217.8 313.7 239.4 297 265.1 290.7C266.2 290.5 267.3 290.2 268.4 290zM397.3 368C390.7 349.4 372.9 336 352 336H288C267.1 336 249.3 349.4 242.7 368H397.3zM248 184C248 144.2 280.2 112 320 112C359.8 112 392 144.2 392 184C392 206.9 381.3 227.4 364.6 240.5C360.7 243.6 356.5 246.3 352 248.5C342.4 253.3 331.5 256 320 256C308.5 256 297.6 253.3 288 248.5C283.5 246.3 279.3 243.6 275.4 240.5C258.7 227.4 248 206.9 248 184V184zM320 208C333.3 208 344 197.3 344 184C344 170.7 333.3 160 320 160C306.7 160 296 170.7 296 184C296 197.3 306.7 208 320 208zM223.8 176C223.8 202.5 202.3 224 175.8 224C149.3 224 127.8 202.5 127.8 176C127.8 149.5 149.3 128 175.8 128C202.3 128 223.8 149.5 223.8 176zM96 309.3C96 279.9 119.9 256 149.3 256H218.7C228.4 256 237.6 258.6 245.5 263.2C210.8 275.4 183 302.1 169.3 336H122.7C107.9 336 96 324.1 96 309.3V309.3zM394.5 263.2C402.4 258.6 411.6 256 421.3 256H490.7C520.1 256 544 279.9 544 309.3C544 324.1 532.1 336 517.3 336H470.7C456.1 302.1 429.2 275.4 394.5 263.2zM512 176C512 202.5 490.5 224 464 224C437.5 224 416 202.5 416 176C416 149.5 437.5 128 464 128C490.5 128 512 149.5 512 176z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Events</div></div></a><a color="indigo" href="https://pris.ly/causes" class="sc-breuTD bQOwBg"><div class="link-icon"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="hands-holding-heart" class="svg-inline--fa fa-hands-holding-heart sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 640 512" color="#5A67D8" width="100%" height="100%" btn=""><path fill="currentColor" d="M176 72.57C176 32.49 208.5 .0003 248.6 .0003C267.8 .0003 286.3 7.646 299.9 21.26L320 41.37L340.1 21.26C353.7 7.646 372.2 0 391.4 0C431.5 0 464 32.49 464 72.57V77.4C464 98.79 455.1 119.2 439.5 133.9L336.4 230.5C327.2 239.2 312.8 239.2 303.6 230.5L200.5 133.9C184.9 119.2 176 98.79 176 77.4V72.57zM144 264.8C156.1 254.3 171.1 248 189.3 248C207.6 248 225.2 255.3 238.2 268.3L299.6 329.7C307.4 337.4 314.2 345.9 320 354.1C325.8 345.9 332.6 337.4 340.4 329.7L401.8 268.3C414.8 255.3 432.4 248 450.7 248C468 248 483.9 254.3 496 264.8V136C496 96.24 528.2 64 568 64C607.8 64 640 96.24 640 136V352.2C640 384.1 627.4 414.6 604.9 437.1L536.1 504.1C527.6 514.3 512.4 514.3 503 504.1C493.7 495.6 493.7 480.4 503 471L570.9 403.1C584.4 389.6 592 371.3 592 352.2V136C592 122.7 581.3 112 568 112C554.7 112 544 122.7 544 136V281.9C544 307.5 533.8 332.1 515.7 350.3L456.1 408.1C447.6 418.3 432.4 418.3 423 408.1C413.7 399.6 413.7 384.4 423 375L438.1 359.1L439 359L465.8 332.3C469.8 328.3 472 322.9 472 317.3C472 305.5 462.5 296 450.7 296C445.1 296 439.7 298.2 435.7 302.2L374.3 363.6C354.9 383 344 409.4 344 436.8V488C344 501.3 333.3 512 320 512C306.7 512 296 501.3 296 488V436.8C296 409.4 285.1 383 265.7 363.6L204.3 302.2C200.3 298.2 194.9 296 189.3 296C177.5 296 168 305.5 168 317.3C168 322.9 170.2 328.3 174.2 332.3L216.1 375C226.3 384.4 226.3 399.6 216.1 408.1C207.6 418.3 192.4 418.3 183 408.1L124.3 350.3C106.2 332.1 96 307.5 96 281.9V136C96 122.7 85.25 112 72 112C58.75 112 48 122.7 48 136V352.2C48 371.3 55.59 389.6 69.09 403.1L136.1 471C146.3 480.4 146.3 495.6 136.1 504.1C127.6 514.3 112.4 514.3 103 504.1L35.15 437.1C12.64 414.6 0 384.1 0 352.2V136C0 96.24 32.24 64 72 64C111.8 64 144 96.24 144 136L144 264.8z"/></svg></div><div><div class="sc-ksZaOG bAtKBi link-title">Causes<svg fill="none" stroke="currentColor" stroke-width="2.5" width="18" height="18" stroke-linecap="round" stroke-linejoin="round"><use xlink:href="/feather-icons.svg#arrow-up-right"/></svg></div></div></a></div><div class="sc-bjUoiL kFMzsw"/><div class="articles"><h4 class="sc-kDDrLX sc-iqcoie ckHlkp kKhVMx">Latest from the blog</h4></div></div></div></div></div></div></div></div><div class="header-cta-container hidden-on-mobile"><a href="/docs/getting-started/quickstart" type="primary" color="indigo" class="sc-dkzDqf fbDpiW">Get Started</a><a class="github-link" href="https://github.com/prisma" target="_blank" rel="noopener"><svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="github" class="svg-inline--fa fa-github sc-fLlhyt lcArFX" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 496 512" color="#fff" width="100%" height="100%" btn=""><path fill="currentColor" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg></a></div></div></div></div></div></div><div class="header__SecondLevelHeader-sc-1w16195-6 flXgSs"><div style="display:flex" class="header__Container-sc-1w16195-1 cODcuA"><div class="overlay__StyledOverlay-sc-1uuldzq-0 fSrhCY"/><div class="input__SearchBoxDiv-sc-1nmahfx-0 ljGOgn"><form><svg width="16" height="16" viewbox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="input__SearchIcon-sc-1nmahfx-1 eRqkOW"><path d="M7 13C10.3137 13 13 10.3137 13 7C13 3.68629 10.3137 1 7 1C3.68629 1 1 3.68629 1 7C1 10.3137 3.68629 13 7 13Z" stroke="#4A5568" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M15 15L12 12" stroke="#4A5568" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><input type="text" placeholder="Search Documentation..." aria-label="Search Documentation..." value=""/><svg width="18" height="28" viewbox="0 0 18 28" fill="none" xmlns="http://www.w3.org/2000/svg" class="input__SearchSlashIcon-sc-1nmahfx-2 jtvDBY"><path d="M11.2734 8.57812L7.01562 20H5.71875L9.97656 8.57812H11.2734Z" fill="#CBD5E0"/><rect x="0.5" y="0.5" width="17" height="27" rx="3.5" stroke="#CBD5E0"/></svg></form></div><div style="width:100%" class="header__NonMobileMenu-sc-1w16195-7 kRNATv"><div class="header__SecondLevelNav-sc-1w16195-11 dtrbjM"><div><a class="header__NavLink-sc-1w16195-8 header__DarkNavLink-sc-1w16195-9 kaReuD dFhGvb non-active" href="/docs/getting-started">Get Started</a><a class="header__NavLink-sc-1w16195-8 header__DarkNavLink-sc-1w16195-9 kaReuD dFhGvb active-item" href="/docs/concepts">Concepts</a><a class="header__NavLink-sc-1w16195-8 header__DarkNavLink-sc-1w16195-9 kaReuD dFhGvb non-active" href="/docs/guides">Guides</a><a class="header__NavLink-sc-1w16195-8 header__DarkNavLink-sc-1w16195-9 kaReuD dFhGvb non-active" href="/docs/reference">Reference</a><a class="header__NavLink-sc-1w16195-8 header__DarkNavLink-sc-1w16195-9 kaReuD dFhGvb non-active" href="/docs/data-platform">Prisma Data Platform</a><a class="header__NavLink-sc-1w16195-8 header__DarkNavLink-sc-1w16195-9 kaReuD dFhGvb non-active" href="/docs/about">About</a></div><div/></div></div><div class="header__DocsMobileButton-sc-1w16195-3 iCsnPT">Docs<svg width="14" height="8" viewbox="0 0 14 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L7 7L13 1" stroke="#718096" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div></div><div class="layout__Wrapper-sc-bupt9j-0 hdlNqm"><div class="layout__Container-sc-bupt9j-4 eRpAkW"><div><section id="sidebar-holder" class="layout__NotMobile-sc-bupt9j-3 bsngme"><aside class="sidebar__SidebarContainer-sc-u94sja-0 frCnUw"><div id="sidebar-container" class="sidebar__Sidebar-sc-u94sja-1 dmeBJu"><ul class="sidebar__List-sc-u94sja-2 isGzdo"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd "><ul class="treeNode__List-sc-a5dz51-0 btdKRc"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd top-level "><a class="active-item" id="/docs/concepts"><span class="">Concepts</span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link "><a class="non-active" id="/docs/concepts/overview"><span class="">Overview</span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/overview/what-is-prisma" href="/docs/concepts/overview/what-is-prisma"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">What is Prisma?</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/overview/why-prisma" href="/docs/concepts/overview/why-prisma"><span class="">Why Prisma?</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/overview/should-you-use-prisma" href="/docs/concepts/overview/should-you-use-prisma"><span class="">Should you use Prisma?</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/overview/prisma-in-your-stack" href="/docs/concepts/overview/prisma-in-your-stack"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Prisma in your stack</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link "><a class="active-item" id="/docs/concepts/components"><span class="">Components</span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="active-item" id="/docs/concepts/components/prisma-schema" href="/docs/concepts/components/prisma-schema"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Prisma schema</span></span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc has-border"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/data-sources" href="/docs/concepts/components/prisma-schema/data-sources"><span class="">Data sources</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/generators" href="/docs/concepts/components/prisma-schema/generators"><span class="">Generators</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/data-model" href="/docs/concepts/components/prisma-schema/data-model"><span class="">Data model</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/names-in-underlying-database" href="/docs/concepts/components/prisma-schema/names-in-underlying-database"><span class="">Names in the underlying database</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/features-without-psl-equivalent" href="/docs/concepts/components/prisma-schema/features-without-psl-equivalent"><span class="">Supporting features without a PSL equivalent</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="active-item" id="/docs/concepts/components/prisma-schema/relations" href="/docs/concepts/components/prisma-schema/relations"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Relations</span></span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc has-border"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/relations/one-to-one-relations" href="/docs/concepts/components/prisma-schema/relations/one-to-one-relations"><span class="">One-to-one relations</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/relations/one-to-many-relations" href="/docs/concepts/components/prisma-schema/relations/one-to-many-relations"><span class="">One-to-many relations</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/relations/many-to-many-relations" href="/docs/concepts/components/prisma-schema/relations/many-to-many-relations"><span class="">Many-to-many relations</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/relations/self-relations" href="/docs/concepts/components/prisma-schema/relations/self-relations"><span class="">Self-relations</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a aria-current="page" class="active-item active-item" id="/docs/concepts/components/prisma-schema/relations/referential-actions" href="/docs/concepts/components/prisma-schema/relations/referential-actions"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Referential actions</span></span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc has-border"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/relations/referential-actions/special-rules-for-referential-actions" href="/docs/concepts/components/prisma-schema/relations/referential-actions/special-rules-for-referential-actions"><span class="">Special rules for referential actions in SQL Server and MongoDB</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/relations/relation-mode" href="/docs/concepts/components/prisma-schema/relations/relation-mode"><span class="">Relation mode</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/relations/troubleshooting-relations" href="/docs/concepts/components/prisma-schema/relations/troubleshooting-relations"><span class="">Troubleshooting relations</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/views" href="/docs/concepts/components/prisma-schema/views"><span class="">Views</span><span class="tag small">Preview</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/indexes" href="/docs/concepts/components/prisma-schema/indexes"><span class="">Indexes</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"><a class="non-active" id="/docs/concepts/components/prisma-schema/postgresql-extensions" href="/docs/concepts/components/prisma-schema/postgresql-extensions"><span class="">PostgreSQL extensions</span><span class="tag small">Preview</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd last-level more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/components/prisma-client" href="/docs/concepts/components/prisma-client"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Prisma Client</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/components/prisma-migrate" href="/docs/concepts/components/prisma-migrate"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Prisma Migrate</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/components/introspection" href="/docs/concepts/components/introspection"><span class="">Introspection</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/components/prisma-cli" href="/docs/concepts/components/prisma-cli"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Prisma CLI</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/components/prisma-studio" href="/docs/concepts/components/prisma-studio"><span class="">Prisma Studio</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/components/prisma-engines" href="/docs/concepts/components/prisma-engines"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Prisma engines</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/components/preview-features" href="/docs/concepts/components/preview-features"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Preview features</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link "><a class="non-active" id="/docs/concepts/database-connectors"><span class="">Database connectors</span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/database-connectors/postgresql" href="/docs/concepts/database-connectors/postgresql"><span class="">PostgreSQL</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/database-connectors/mysql" href="/docs/concepts/database-connectors/mysql"><span class="">MySQL</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/database-connectors/sqlite" href="/docs/concepts/database-connectors/sqlite"><span class="">SQLite</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/database-connectors/mongodb" href="/docs/concepts/database-connectors/mongodb"><span class="">MongoDB</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/database-connectors/cockroachdb" href="/docs/concepts/database-connectors/cockroachdb"><span class="">CockroachDB</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/database-connectors/sql-server" href="/docs/concepts/database-connectors/sql-server"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Microsoft SQL Server</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link "><a class="non-active" id="/docs/concepts/more"><span class="">More</span></a><ul class="treeNode__List-sc-a5dz51-0 btdKRc"><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/more/telemetry" href="/docs/concepts/more/telemetry"><span class="">Telemetry</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd more-padding"><a class="non-active" id="/docs/concepts/more/comparisons" href="/docs/concepts/more/comparisons"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Comparing Prisma</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 jVyuJd top-level "/></ul></li></ul></li></ul></div></aside></section></div><article class="layout__Content-sc-bupt9j-1 kgCJAK"><div class="layout__MaxWidth-sc-bupt9j-2 gGGkRx"><section class="top-section"><div class="topSection__TopSectionWrapper-sc-d3j04s-0 eobxJN"><div class="topSection__Header-sc-d3j04s-1 mBQum"><div class="title"><div class="parentTitleComp__BreadcrumbTitle-sc-f3mbxz-0 bTZEks"><span><a href="/docs/concepts"><span class="">Concepts</span></a> / </span><span><a href="/docs/concepts/components"><span class="">Components</span></a> / </span><span><a href="/docs/concepts/components/prisma-schema"><span class="">Prisma schema</span></a> / </span><span><a href="/docs/concepts/components/prisma-schema/relations"><span class="">Relations</span></a></span></div><h1 class="topSection__MainTitle-sc-d3j04s-2 cOIGMt">Referential actions</h1></div><div class="tech-switch-block"/></div></div></section><section><p class="paragraph">Referential actions determine what happens to a record when your application deletes or updates a related record.</p><p class="paragraph">From version 2.26.0, you can define referential actions on the relation fields in your Prisma schema. This allows you to define referential actions like cascading deletes and cascading updates at a Prisma level.</p><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-2 kEPLyH"><div class="admonition__FlexContainer-sc-htoeam-0 jaIKZT"><div class="admonition__ChildContainer-sc-htoeam-1 cviBXA"><strong>Version differences</strong></div><div class="admonition__ChildContainer-sc-htoeam-1 cviBXA"><li>If you use version 3.0.1 or later, you can use referential actions as described on this page.</li><li>If you use a version between 2.26.0 and 3.0.0, you can use referential actions as described on this page, but you must <a href="/docs/concepts/components/preview-features/client-preview-features#enabling-a-prisma-client-preview-feature">enable the preview feature flag</a> <code class="inline-code">referentialActions</code>.</li><li>If you use version 2.25.0 or earlier, you can configure cascading deletes manually in your database.</li></div></div></span><p class="paragraph">In the following example, adding <code class="inline-code">onDelete: Cascade</code> to the <code class="inline-code">author</code> field on the <code class="inline-code">Post</code> model means that deleting the <code class="inline-code">User</code> record will also delete all related <code class="inline-code">Post</code> records.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-highlight-color)">4</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">5</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">If you do not specify a referential action, Prisma <a href="#referential-action-defaults">uses a default</a>.</p></section><span type="alert" class="admonition__AdmonitionWrapper-sc-htoeam-2 iZdAlS"><span class="alert-circle"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg></span><p class="paragraph">If you upgrade from a version earlier than 2.26.0: It is extremely important that you check the <a href="/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-3/referential-actions">upgrade paths for referential actions</a> section. Prisma support of referential actions <strong>removes the safety net in Prisma Client that prevents cascading deletes at runtime</strong>. If you use the feature <em>without upgrading your database</em>, the <a href="/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-3/referential-actions#prisma-2x-default-referential-actions">old default action</a> - <code class="inline-code">ON DELETE CASCADE</code> - becomes active. This might result in cascading deletes that you did not expect.</p></span><section><h2 id="what-are-referential-actions" style="position:relative"><a href="#what-are-referential-actions" aria-label="what are referential actions permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>What are referential actions?</h2><p class="paragraph">Referential actions are policies that define how a referenced record is handled by the database when you run an <a href="/docs/concepts/components/prisma-client/crud#update"><code class="inline-code">update</code></a> or <a href="/docs/concepts/components/prisma-client/crud#delete"><code class="inline-code">delete</code></a> query.</p><div class="collapsible__Wrapper-sc-atw4gb-0 eOVlNr"><div class="collapsible__Tab-sc-atw4gb-1 iRNoIX"><input type="checkbox" id="tab-126" name="tab" class="collapsible__Input-sc-atw4gb-4 cvYxhA"/><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="collapsible__StyledArrow-sc-atw4gb-5 ctFhqK"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><label for="tab-126" class="collapsible__Label-sc-atw4gb-2 gdBdPv">Referential actions on the database level</label><div class="collapsible__TabContent-sc-atw4gb-3 fbIwbb tab-content"><p class="paragraph">Referential actions are features of foreign key constraints that exist to preserve referential integrity in your database.</p><p class="paragraph">When you define relationships between data models in your Prisma schema, you use <a href="/docs/concepts/components/prisma-schema#relation-fields">relation fields</a>, <strong>which do not exist on the database</strong>, and <a href="/docs/concepts/components/prisma-schema/data-model#scalar-fields">scalar fields</a>, <strong>which do exist on the database</strong>. These foreign keys connect the models on the database level.</p><p class="paragraph">Referential integrity states that these foreign keys must reference an existing primary key value in the related database table. In your Prisma schema, this is generally represented by the <code class="inline-code">id</code> field on the related model.</p><p class="paragraph">By default a database will reject any operation that violates the referential integrity, for example, by deleting referenced records.</p></div></div></div><section><h3 id="how-to-use-referential-actions" style="position:relative"><a href="#how-to-use-referential-actions" aria-label="how to use referential actions permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>How to use referential actions</h3><p class="paragraph">Referential actions are defined in the <a href="/docs/reference/api-reference/prisma-schema-reference#relation"><code class="inline-code">@relation</code></a> attribute and map to the actions on the <strong>foreign key constraint</strong> in the underlying database. If you do not specify a referential action, <a href="#referential-action-defaults">Prisma falls back to a default</a>.</p><p class="paragraph">The following model defines a one-to-many relation between <code class="inline-code">User</code> and <code class="inline-code">Post</code> and a many-to-many relation between <code class="inline-code">Post</code> and <code class="inline-code">Tag</code>, with explicitly defined referential actions:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">4</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">5</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> tags</span><span class="token type-class-name"> TagOnPosts</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token not-class"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-highlight-color)">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token not-class"> User</span><span class="token type-class-name"> User</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">userId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> SetNull</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> userId</span><span class="token type-class-name"> Int</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">12</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">13</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">14</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> TagOnPosts</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">15</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-highlight-color)">16</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> post</span><span class="token type-class-name"> Post</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">postId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-highlight-color)">17</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> tag</span><span class="token type-class-name"> Tag</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">tagId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">18</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> postId</span><span class="token type-class-name"> Int</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">19</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> tagId</span><span class="token type-class-name"> Int</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">20</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">21</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">22</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Tag</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">23</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">24</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> name</span><span class="token type-class-name"> String</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@unique</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">25</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> TagOnPosts</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">26</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">This model explicitly defines the following referential actions:</p><ul class="list"><li>If you delete a <code class="inline-code">Tag</code>, the corresponding tag assignment is also deleted in <code class="inline-code">TagOnPosts</code>, using the <code class="inline-code">Cascade</code> referential action</li><li>If you delete a <code class="inline-code">User</code>, the author is removed from all posts by setting the field value to <code class="inline-code">Null</code>, because of the <code class="inline-code">SetNull</code> referential action. To allow this, <code class="inline-code">User</code> and <code class="inline-code">userId</code> must be optional fields in <code class="inline-code">Post</code>.</li></ul><p class="paragraph">Prisma supports the following referential actions:</p><ul class="list"><li><a href="#cascade"><code class="inline-code">Cascade</code></a></li><li><a href="#restrict"><code class="inline-code">Restrict</code></a></li><li><a href="#noaction"><code class="inline-code">NoAction</code></a></li><li><a href="#setnull"><code class="inline-code">SetNull</code></a></li><li><a href="#setdefault"><code class="inline-code">SetDefault</code></a></li></ul></section><section><h3 id="referential-action-defaults" style="position:relative"><a href="#referential-action-defaults" aria-label="referential action defaults permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Referential action defaults</h3><p class="paragraph">If you do not specify a referential action, Prisma uses the following defaults:</p><div class="table__TableWrapper-sc-18kfzv9-0 dONZdc"><table><thead><tr><th align="left">Clause</th><th align="left">Optional relations</th><th align="left">Mandatory relations</th></tr></thead><tbody><tr><td align="left"><code class="inline-code">onDelete</code></td><td align="left"><code class="inline-code">SetNull</code></td><td align="left"><code class="inline-code">Restrict</code></td></tr><tr><td align="left"><code class="inline-code">onUpdate</code></td><td align="left"><code class="inline-code">Cascade</code></td><td align="left"><code class="inline-code">Cascade</code></td></tr></tbody></table></div><p class="paragraph">For example, in the following schema all <code class="inline-code">Post</code> records must be connected to a <code class="inline-code">User</code> via the <code class="inline-code">author</code> relation:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color)"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">The schema does not explicitly define referential actions on the mandatory <code class="inline-code">author</code> relation field, which means that the default referential actions of <code class="inline-code">Restrict</code> for <code class="inline-code">onDelete</code> and <code class="inline-code">Cascade</code> for <code class="inline-code">onUpdate</code> apply.</p></section></section><section><h2 id="caveats" style="position:relative"><a href="#caveats" aria-label="caveats permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Caveats</h2><p class="paragraph">The following caveats apply:</p><ul class="list"><li>Referential actions are <strong>not</strong> supported on <a href="/docs/concepts/components/prisma-schema/relations/many-to-many-relations#implicit-many-to-many-relations">implicit many-to-many relations</a>. To use referential actions, you must define an explicit many-to-many relation and define your referential actions on the <a href="/docs/concepts/components/prisma-schema/relations/troubleshooting-relations#how-to-use-a-relation-table-with-a-many-to-many-relationship">join table</a>.</li><li>Certain combinations of referential actions and required/optional relations are incompatible. For example, using <code class="inline-code">SetNull</code> on a required relation will lead to database errors when deleting referenced records because the non-nullable constraint would be violated. See <a href="https://github.com/prisma/prisma/issues/7909">this GitHub issue</a> for more information.</li></ul></section><section><h2 id="types-of-referential-actions" style="position:relative"><a href="#types-of-referential-actions" aria-label="types of referential actions permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Types of referential actions</h2><p class="paragraph">The following table shows which referential action each database supports.</p><div class="table__TableWrapper-sc-18kfzv9-0 dONZdc"><table><thead><tr><th align="left">Database</th><th align="left">Cascade</th><th align="left">Restrict</th><th align="left">NoAction</th><th align="left">SetNull</th><th align="left">SetDefault</th></tr></thead><tbody><tr><td align="left">PostgreSQL</td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong>⌘</td><td align="left"><strong>✔️</strong></td></tr><tr><td align="left">MySQL</td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left">❌ (✔️†)</td></tr><tr><td align="left">SQLite</td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td></tr><tr><td align="left">SQL Server</td><td align="left"><strong>✔️</strong></td><td align="left"><strong>❌</strong>‡</td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td></tr><tr><td align="left">CockroachDB</td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td></tr><tr><td align="left">MongoDB††</td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>✔️</strong></td><td align="left"><strong>❌</strong></td></tr></tbody></table></div><ul class="list"><li>† See <a href="#mysql">special cases for MySQL</a>.</li><li>⌘ See <a href="#postgresql">special cases for PostgreSQL</a>.</li><li>‡ See <a href="#sql-server">special cases for SQL Server</a>.</li><li>†† Referential actions for MongoDB are available in Prisma versions 3.7.0 and later.</li></ul><section><h3 id="special-cases-for-referential-actions" style="position:relative"><a href="#special-cases-for-referential-actions" aria-label="special cases for referential actions permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>MySQL</h4><p class="paragraph">MySQL, and the underlying InnoDB storage engine, does not support <code class="inline-code">SetDefault</code>. The exact behavior depends on the database version:</p><ul class="list"><li>In MySQL versions 8 and later, and MariaDB versions 10.5 and later, <code class="inline-code">SetDefault</code> effectively acts as an alias for <code class="inline-code">NoAction</code>. You can define tables using the <code class="inline-code">SET DEFAULT</code> referential action, but a foreign key constraint error is triggered at runtime.</li><li>In MySQL versions 5.6 and later, and MariaDB versions before 10.5, attempting to create a table definition with the <code class="inline-code">SET DEFAULT</code> referential action fails with a syntax error.</li></ul><p class="paragraph">For this reason, when you set <code class="inline-code">mysql</code> as the database provider, Prisma warns users to replace <code class="inline-code">SetDefault</code> referential actions in the Prisma schema with another action.</p></section><section><h4 id="postgresql" style="position:relative"><a href="#postgresql" aria-label="postgresql permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>PostgreSQL</h4><p class="paragraph">PostgreSQL is the only database supported by Prisma that allows you to define a <code class="inline-code">SetNull</code> referential action that refers to a non-nullable field. However, this raises a foreign key constraint error when the action is triggered at runtime.</p><p class="paragraph">For this reason, when you set <code class="inline-code">postgres</code> as the database provider in the (default) <code class="inline-code">foreignKeys</code> relation mode, Prisma warns users to mark as optional any fields that are included in a <code class="inline-code">@relation</code> attribute with a <code class="inline-code">SetNull</code> referential action. For all other database providers, Prisma rejects the schema with a validation error.</p></section><section><h4 id="sql-server" style="position:relative"><a href="#sql-server" aria-label="sql server permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Example usage</h4><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-added-color)">+</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">5</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h5 id="result-of-using-cascade" style="position:relative"><a href="#result-of-using-cascade" aria-label="result of using cascade permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Example usage</h4><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-added-color)">+</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> Restrict</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> Restrict</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">5</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h5 id="result-of-using-restrict" style="position:relative"><a href="#result-of-using-restrict" aria-label="result of using restrict permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>NoAction</inlinecode></h3><p class="paragraph">The <code class="inline-code">NoAction</code> action is similar to <code class="inline-code">Restrict</code>, the difference between the two is dependent on the database being used:</p><ul class="list"><li><strong>PostgreSQL</strong>: <code class="inline-code">NoAction</code> allows the check (if a referenced row on the table exists) to be deferred until later in the transaction. See <a href="https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK">the PostgreSQL docs</a> for more information.</li><li><strong>MySQL</strong>: <code class="inline-code">NoAction</code> behaves exactly the same as <code class="inline-code">Restrict</code>. See <a href="https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html#foreign-key-referential-actions">the MySQL docs</a> for more information.</li><li><strong>SQLite</strong>: When a related primary key is modified or deleted, no action is taken. See <a href="https://www.sqlite.org/foreignkeys.html#fk_actions">the SQLite docs</a> for more information.</li><li><strong>SQL Server</strong>: When a referenced record is deleted or modified, an error is raised. See <a href="https://docs.microsoft.com/en-us/sql/relational-databases/tables/graph-edge-constraints?view=sql-server-ver15#on-delete-referential-actions-on-edge-constraints">the SQL Server docs</a> for more information.</li><li><strong>MongoDB</strong> (in preview from version 3.6.0): When a record is modified or deleted, nothing is done to any related records.</li></ul><span type="warning" class="admonition__AdmonitionWrapper-sc-htoeam-2 FeEGX"><p class="paragraph">If you are <a href="/docs/concepts/components/prisma-schema/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode">managing relations in the Prisma Client</a> rather than using foreign keys in the database, you should be aware that currently Prisma only implements the referential actions. Foreign keys also create constraints, which make it impossible to manipulate data in a way that would violate these constraints: instead of executing the query, the database responds with an error. These constraints will not be created if you emulate referential integrity in the client, so if you set the referential action to <code class="inline-code">NoAction</code> there will be no checks to prevent you from breaking the referential integrity.</p></span><section><h4 id="example-usage-2" style="position:relative"><a href="#example-usage-2" aria-label="example usage 2 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Example usage</h4><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-added-color)">+</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> NoAction</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> NoAction</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">5</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h5 id="result-of-using-noaction" style="position:relative"><a href="#result-of-using-noaction" aria-label="result of using noaction permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>SetNull</inlinecode></h3><ul class="list"><li><p class="paragraph"><code class="inline-code">onDelete: SetNull</code> The scalar field of the referencing object will be set to <code class="inline-code">NULL</code>.</p></li><li><p class="paragraph"><code class="inline-code">onUpdate: SetNull</code> When updating the identifier of a referenced object, the scalar fields of the referencing objects will be set to <code class="inline-code">NULL</code>.</p></li></ul><p class="paragraph"><code class="inline-code">SetNull</code> will only work on optional relations. On required relations, a runtime error will be thrown since the scalar fields cannot be null.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-added-color)">+</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> SetNull</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> SetNull</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">5</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h5 id="result-of-using-setnull" style="position:relative"><a href="#result-of-using-setnull" aria-label="result of using setnull permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>SetDefault</inlinecode></h3><ul class="list"><li><p class="paragraph"><code class="inline-code">onDelete: SetDefault</code> The scalar field of the referencing object will be set to the fields default value.</p></li><li><p class="paragraph"><code class="inline-code">onUpdate: SetDefault</code> The scalar field of the referencing object will be set to the fields default value.</p></li></ul><p class="paragraph">These require setting a default for the relation scalar field with <a href="/docs/reference/api-reference/prisma-schema-reference#default"><code class="inline-code">@default</code></a>. If no defaults are provided for any of the scalar fields, a runtime error will be thrown.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-added-color)">+</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorUsername</span><span class="token type-class-name"> String</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"anonymous"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no" style="color:var(--code-added-color)">+</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorUsername</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">username</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> SetDefault</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onUpdate:</span><span class="token type-class-name"> SetDefault</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> username</span><span class="token type-class-name"> String</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h5 id="result-of-using-setdefault" style="position:relative"><a href="#result-of-using-setdefault" aria-label="result of using setdefault permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Upgrade paths from versions 2.25.0 and earlier</h2><p class="paragraph">There are a couple of paths you can take when upgrading which will give different results depending on the desired outcome.</p><p class="paragraph">If you currently use the migration workflow, you can run an introspection to check how the defaults are reflected in your schema. You can then manually update your database if you need to.</p><p class="paragraph">You can also decide to skip checking the defaults and run a migration to update your database with the <a href="#referential-action-defaults">new default values</a>.</p><p class="paragraph">The following assumes you have upgraded to 2.26.0 or newer and enabled the preview feature flag, or upgraded to 3.0.0 or newer:</p><section><h3 id="using-introspection" style="position:relative"><a href="#using-introspection" aria-label="using introspection permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Using Introspection</h3><p class="paragraph">If you <a href="/docs/concepts/components/introspection">Introspect</a> your database, the referential actions configured at the database level will be reflected in your Prisma Schema. If you have been using Prisma Migrate or <code class="inline-code">prisma db push</code> to manage the database schema, these are likely to be the <a href="#the-default-referential-actions">default values</a> from 2.25.0 and earlier.</p><p class="paragraph">When you run an Introspection, Prisma compares all the foreign keys in the database with the schema, if the SQL statements <code class="inline-code">ON DELETE</code> and <code class="inline-code">ON UPDATE</code> do <strong>not</strong> match the default values, they will be explicitly set in the schema file.</p><p class="paragraph">After introspecting, you can review the non-default clauses in your schema. The most important clause to review is <code class="inline-code">onDelete</code>, which defaults to <code class="inline-code">Cascade</code> in 2.25.0 and earlier.</p><span type="alert" class="admonition__AdmonitionWrapper-sc-htoeam-2 iZdAlS"><span class="alert-circle"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg></span><p class="paragraph">If you are using either the <a href="/docs/concepts/components/prisma-client/crud#delete-a-single-record"><code class="inline-code">delete()</code></a> or <a href="/docs/concepts/components/prisma-client/crud#delete-all-records"><code class="inline-code">deleteMany()</code></a> methods, <strong><a href="#how-to-use-cascading-deletes">cascading deletes</a> will now be performed</strong> as the <code class="inline-code">referentialActions</code> preview feature <strong>removed the safety net in Prisma Client that previously prevented cascading deletes at runtime</strong>. Be sure to check your code and make any adjustments accordingly.</p></span><p class="paragraph">Make sure you are happy with every case of <code class="inline-code">onDelete: Cascade</code> in your schema. If not, either:</p><ul class="list"><li>Modify your Prisma schema and <code class="inline-code">db push</code> or <code class="inline-code">dev migrate</code> to change the database</li></ul><p class="paragraph"><em>or</em></p><ul class="list"><li>Manually update the underlying database if you use an introspection-only workflow</li></ul><p class="paragraph">The following example would result in a cascading delete, if the <code class="inline-code">User</code> is deleted then all of their <code class="inline-code">Post</code>'s will be deleted too.</p><section><h4 id="a-blog-schema-example" style="position:relative"><a href="#a-blog-schema-example" aria-label="a blog schema example permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>A blog schema example</h4><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> Cascade</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section><section><h3 id="using-migration" style="position:relative"><a href="#using-migration" aria-label="using migration permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Using Migration</h3><p class="paragraph">When running a <a href="/docs/concepts/components/prisma-migrate">Migration</a> (or the <a href="/docs/concepts/components/prisma-migrate/db-push"><code class="inline-code">prisma db push</code></a> command) the <a href="#referential-action-defaults">new defaults</a> will be applied to your database.</p><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-2 kEPLyH"><p class="paragraph">Unlike when you run an Introspect for the first time, the new referential actions clause and property, will <strong>not</strong> automatically be added to your prisma schema by the Prisma VSCode extension. You will have to manually add them if you wish to use anything other than the new defaults.</p></span><p class="paragraph">Explicitly defining referential actions in your Prisma schema is optional. If you do not explicitly define a referential action for a relation, Prisma uses the <a href="#referential-action-defaults">new defaults</a>.</p><p class="paragraph">Note that referential actions can be added on a case by case basis. This means that you can add them to one single relation and leave the rest set to the defaults by not manually specifying anything.</p></section><section><h3 id="checking-for-errors" style="position:relative"><a href="#checking-for-errors" aria-label="checking for errors permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Checking for errors</h3><p class="paragraph"><strong>Before</strong> upgrading to 2.26.0 and enabling the referential actions <strong>preview feature</strong>, Prisma prevented the deletion of records while using <code class="inline-code">delete()</code> or <code class="inline-code">deleteMany()</code> to preserve referential integrity. A custom runtime error would be thrown by the Prisma Client with the error code <code class="inline-code">P2014</code>.</p><p class="paragraph"><strong>After</strong> upgrading and enabling the referential actions <strong>preview feature</strong>, Prisma no longer performs runtime checks. You can instead specify a custom referential action to preserve the referential integrity between relations.</p><p class="paragraph">When you use <a href="#noaction"><code class="inline-code">NoAction</code></a> or <a href="#restrict"><code class="inline-code">Restrict</code></a> to prevent the deletion of records, the error messages will be different post 2.26.0 compared to pre 2.26.0. This is because they are now triggered by the database and <strong>not</strong> the Prisma Client. The new error code that can be expected is <code class="inline-code">P2003</code>.</p><p class="paragraph">To make sure you catch these new errors you can adjust your code accordingly.</p><section><h4 id="example-of-catching-errors" style="position:relative"><a href="#example-of-catching-errors" aria-label="example of catching errors permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Example of catching errors</h4><p class="paragraph">The following example uses the below blog schema with a one-to-many relationship between <code class="inline-code">Post</code> and <code class="inline-code">User</code> and sets a <a href="#restrict"><code class="inline-code">Restrict</code></a> referential actions on the <code class="inline-code">author</code> field.</p><p class="paragraph">This means that if a user has a post, that user (and their posts) <strong>cannot</strong> be deleted.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 jLYujF"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>schema.prisma</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">1</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">2</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">3</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">4</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">onDelete:</span><span class="token type-class-name"> Restrict</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">5</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> authorId</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">6</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">7</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">8</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">9</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">10</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineNo-sc-8eixcc-4 keieLb line-no">11</span><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">Prior to upgrading and enabling the referential actions <strong>preview feature</strong>, the error code you would receive when trying to delete a user which has posts would be <code class="inline-code">P2014</code> and it's message:</p><blockquote><p class="paragraph">"The change you are trying to make would violate the required relation '{relation_name}' between the {model_a_name} and {model_b_name} models."</p></blockquote><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">try</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">delete</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'some-long-id'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">catch</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error </span><span class="token keyword" style="color:#00009f">instanceof</span><span class="token plain"> </span><span class="token class-name maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token known-class-name class-name">PrismaClientKnownRequestError</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">code</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">===</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'P2014'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">message</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">catch</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">throw</span><span class="token plain"> e</span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">finally</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">To make sure you are checking for the correct errors in your code, modify your check to look for <code class="inline-code">P2003</code>, which will deliver the message:</p><blockquote><p class="paragraph">"Foreign key constraint failed on the field: {field_name}"</p></blockquote><pre><div class="code__CodeWrapper-sc-8eixcc-0 gMcijM codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 sHeXY prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fpfsPR copy-button"><div class="copy__CopyComponent-sc-eodafv-0 BkNgj"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">try</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">delete</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'some-long-id'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">catch</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error </span><span class="token keyword" style="color:#00009f">instanceof</span><span class="token plain"> </span><span class="token class-name maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token known-class-name class-name">PrismaClientKnownRequestError</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-deleted-bg-color);symb-color:var(--code-deleted-color)"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">code</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">===</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'P2014'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:var(--code-added-bg-color);symb-color:var(--code-added-color)"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">code</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">===</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'P2003'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">error</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">message</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"/><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">catch</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">throw</span><span class="token plain"> e</span></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">finally</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 cdGjbH token-line" style="background-color:;symb-color:"><span class="code__LineContent-sc-8eixcc-5 laqNCI "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h2 id="behavior-without-using-referentialactions" style="position:relative"><a href="#behavior-without-using-referentialactions" aria-label="behavior without using inlinecodereferentialactionsinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg">
推荐文章
伤情的核桃
·
马斯洛需求层次理论与购买动机 - 消费心理学 - Copymate
1 月前
宽容的野马
·
c语言中如何让一个语句只执行一次 | PingCode智库
2 月前
高大的苹果
·
[SOLVED] opencv / AUR Issues, Discussion & PKGBUILD Requests / Arch Linux Forums
3 月前
私奔的登山鞋
·
Issue 45285: c_char incorrectly treated as bytes in Structure - Python tracker
4 月前
温暖的遥控器
·
springboot 重定向(HttpServletResponse实现)_springboot sendredirect 502-CSDN博客
6 月前