Hi @cgarrotti 👋

At the moment, Prisma does not have support for model inheritance. However, we do have a feature request for it.

  • #12604

You can add your use case to the feature request and leave a 👍 to help our engineers prioritize it.

If this answers your question, it would be great if you could mark this Discussion as answered to indicate that it has been resolved.

Otherwise please let us know how else we can help you further or close the Discussion if it was resolved in some other way 🙏

🌐
Prisma
prisma.io › home › table inheritance › table inheritance › table inheritance › table inheritance
Table inheritance | Prisma Documentation
Learn about the use cases and patterns ... in your application. Table inheritance is a software design pattern that allows the modeling of hierarchical relationships between entities....
🌐
Basedash
basedash.com › home › blog › how to model inheritance in prisma
How to model inheritance in Prisma | Basedash
March 29, 2022 - Learn how to effectively use inheritance and polymorphic relationships in Prisma ORM through practical examples. Understand Class Table Inheritance and…
Discussions

prism support inheritance in model ?
Question prism support inheritance in model ? How to reproduce (optional) prism support inheritance in model ? Expected behavior (optional) No response Information about Prisma Schema, Client Queri... More on github.com
🌐 github.com
1
1
August 2, 2023
model with pre-defined sub-model
You've gone full bot mode! Let me fetch that AI answer for you ASAP. Currently, Prisma does not natively support model inheritance or the ability to define a "sub-model" (like your LogInfo) and extend it in other models directly in the Prisma schema. This means you cannot write something like ... More on answeroverflow.com
🌐 answeroverflow.com
July 1, 2025
database - How to handle inheritnace with Prisma? - Stack Overflow
Inheritance is not currently supported in Prisma. There is an existing issue which describes progress and ideas on how schema.prisma file can support implementing interfaces where multiple models could implement the same interface. More on stackoverflow.com
🌐 stackoverflow.com
node.js - Is there is any support for Single Table Inheritance in Prisma? - Stack Overflow
I have one project in Rails where I used Single Table Inheritance on Users Table, by creating two roles for Users table - 1.Clinician and 2.Patient. The model desc. is below · class Patient < User has_many :clinician_patients has_many :clinicians, through: :clinician_patients end · class Clinician < User has_many :clinician_patients has_many :patients, through: :clinician_patients end ... I am new to Prisma ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
ZenStack
zenstack.dev › blog › polymorphism
Tackling Polymorphism in Prisma | ZenStack
December 21, 2023 - The most natural way to model inheritance is with inheritance. ZModel already allows you to declare abstract models and inherit from them. However, it's simply a syntactic sugar for inserting all fields of the base model into the sub-one.
🌐
Answer Overflow
answeroverflow.com › m › 1389555104428068886
model with pre-defined sub-model - Prisma
July 1, 2025 - } In summary: Prisma does not support sub-models or inheritance natively. You need to copy fields or use a third-party tool for this functionality.
Find elsewhere
🌐
Prisma
prisma.io › home › data modeling › data modeling › data modeling › data modeling › data modeling
Data modeling with Prisma | Prisma Documentation
The resulting user object is an instance of Sequelize's Model class (because User inherits from Model). It's not a POJO, but an object that implements additional behavior from Sequelize. Depending on which parts of Prisma ORM you want to use in your application, the data modeling flow looks ...
🌐
RedwoodJS Community
community.redwoodjs.com › get help and help others
Modeling Inheritance in Redwood+Prisma - Get Help and Help Others - RedwoodJS Community
October 23, 2022 - Hi all, Is there a preferred way to model inheritance in Redwood+Prisma? From what I found, prisma is lacking deeper support for this. The solution I was thinking of is along the lines of what’s described here: https://…
🌐
GitHub
github.com › prisma › prisma › discussions › 2342
inheritance · prisma/prisma · Discussion #2342
Problem i need to use base modeling Solution a data model which will inherit from another data model Alternatives none i can think of Additional context none
Author   prisma
🌐
GitHub
github.com › prisma › docs › blob › main › content › 200-orm › 100-prisma-schema › 20-data-model › 80-table-inheritance.mdx
docs/content/200-orm/100-prisma-schema/20-data-model/80-table-inheritance.mdx at main · prisma/docs
Learn about the use cases and patterns ... your application. ... Table inheritance is a software design pattern that allows the modeling of hierarchical relationships between entities....
Author   prisma
🌐
DEV Community
dev.to › zenstack › tackling-polymorphism-in-prisma-2o0a
Tackling Polymorphism in Prisma - DEV Community
October 21, 2024 - The most natural way to model inheritance is with inheritance. ZModel already allows you to declare abstract models and inherit from them. However, it's simply a syntactic sugar for inserting all fields of the base model into the sub-one.
Top answer
1 of 2
1

In short: No there is such thing as abstract models or inheritance in general implemented in Prisma as of now.

However there is an open Github issue proposal which describes how interfaces could be used for that kind of abstraction. https://github.com/prisma/prisma/issues/2506. Unfortunately there hasn't been made any real progress on the issue since 2020.


Thus people started to implement it by themselves. A custom library called ZenStack built on top of Prisma offers abstract models. You can define .zmodel model files which are compiled to the normal prisma.schema.

An example from the ZenStack documentation:

abstract model Basic {
    id String @id
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
}

model User extends Basic {
    name String 
}

The generated prisma file only contains one User model:

model User {
    id String @id
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
    name String @id
}
2 of 2
0

Prisma ORM does not have the concept of "abstract models" in the same way Django ORM does. In Django, an abstract model serves as a base class for other models but does not produce a database table of its own. Instead, its fields are added to the child models that inherit from it.

In Prisma, you can't define a model that is only used for inheritance purposes. However, there are certain approaches you can take to emulate abstract-like behavior:

Using Generators or Scripts:

You could set up a generator or a script to produce the final schema.prisma file by combining shared fields and model-specific fields. This is a more involved setup but can help maintain DRYness if you have a lot of shared fields.

Model Relations instead of Inheritance:

Consider if a relation between models might serve better than inheritance. For instance, if there's a shared set of attributes across multiple models, those attributes could be refactored into their own model, and a relation could be established.

model Profile {
  id      Int    @id @default(autoincrement())
  name    String
  email   String @unique
  user    User?  @relation(fields: [userId], references: [id])
  userId  Int?
  admin   Admin? @relation(fields: [adminId], references: [id])
  adminId Int?
}

model User {
  id      Int      @id @default(autoincrement())
  profile Profile  @relation(fields: [profileId], references: [id])
  profileId Int
  // ... other specific fields ...
}

model Admin {
  id      Int      @id @default(autoincrement())
  profile Profile  @relation(fields: [profileId], references: [id])
  profileId Int
  // ... other specific fields ...
}

In this example, the Profile model holds fields common to both User and Admin.

🌐
Prisma
prisma.io › home › prisma orm
What is Prisma ORM? (Overview) | Prisma Documentation
November 3, 2020 - datasource db { provider = "postgresql" } generator client { provider = "prisma-client" output = "./generated" } model User { id Int @id @default(autoincrement()) email String @unique name String? posts Post[] } model Post { id Int @id @default(autoincrement()) title String published Boolean @default(false) author User?
🌐
Prisma
prisma.io › dataguide › datamodeling › know-your-problem-space
Data Modeling | Know Your Problem Space | Prisma's Data Guide
Every additional node or edge complicates the graph, which in turn means maintaining and improving the data model further will require more effort. However, this complexity is a local as well as a global concern. Sets of entities can be connected in tangles of important-enough relationships, which are challenging both to manage and to use. These subsystems can often be shielded to some extent by mechanisms like views or table inheritance as in PostgreSQL, with a net effect not unlike the Façade pattern in object-oriented software development.
🌐
Prisma
prisma.io › home › models › models › models › models
Models | Prisma Documentation
In relational databases like PostgreSQL and MySQL, a model maps to a table ... Note: In the future there might be connectors for non-relational databases and other data sources. For example, for a REST API it would map to a resource. The following query creates a User with nested Post and Category records: const user = await prisma.user.create({ data: { email: "ariadne@prisma.io", name: "Ariadne", posts: { create: [ { title: "My first day at Prisma", categories: { create: { name: "Office" } }, }, { title: "How to connect to a SQLite database", categories: { create: [{ name: "Databases" }, { name: "Tutorials" }] }, }, ], }, }, });
🌐
Prisma
prisma.io › ecosystem
Prisma ORM Ecosystem
A generator, which takes a Prisma 2 schema.prisma and generates a JSON Schema in flavor which MongoDB accepts ... Merge multiple files, create model inheritance and abstraction and create cross-file relations.
🌐
Twitter
twitter.com › prisma › status › 1454041069360799744
October 29, 2021 - We cannot provide a description for this page right now