You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I would like to request a feature that allows truncating all tables and their relations and resetting their IDs in Prisma. The equivalent SQL command would be:
Use Case:
This feature would be particularly useful for development and testing environments where we often need to reset the database state. Being able to truncate all tables and reset the IDs ensures that we can start with a clean slate without any residual data.
Proposed Solution:
Provide a method or command in Prisma that allows for truncating all tables and resetting their IDs. This could be implemented as a CLI command or as part of the Prisma client API.
Additional Context:
Currently, developers have to manually write SQL scripts or use raw queries to achieve this. Having a built-in method in Prisma would streamline the process and reduce the potential for errors.
Hi, currently you may use await prisma.tableName.deleteMany() to truncate the table tableName, though we have no higher-level API for RESTART IDENTITY CASCADE.
May we ask what the use case behind asking to reset the @id @default(autoincrement()) counter is?
This would allow us to better assess the possible future next steps with this feature request. Thanks.
We’ve noticed there hasn’t been activity on this issue for quite some time, and we suspect it might no longer be relevant. As part of our ongoing effort to streamline open issues in this repository, we’re closing this one to focus on what’s most important to our community.
If you believe this issue is still relevant and requires attention, feel free to reopen it. Reopening the issue is a valuable signal to us about what matters most to you.
You can learn more about our approach and motivations in the Prisma ORM Manifesto.
Activity
[-]functionality to truncate all tables and reset IDs[/-][+]Truncate all tables and reset IDs[/+]jkomyno commentedon Jul 10, 2024
Hi, currently you may use
await prisma.tableName.deleteMany()to truncate the tabletableName, though we have no higher-level API forRESTART IDENTITY CASCADE.May we ask what the use case behind asking to reset the
@id @default(autoincrement())counter is?This would allow us to better assess the possible future next steps with this feature request. Thanks.
FGoessler commentedon Jan 23, 2025
Hi,
We’ve noticed there hasn’t been activity on this issue for quite some time, and we suspect it might no longer be relevant. As part of our ongoing effort to streamline open issues in this repository, we’re closing this one to focus on what’s most important to our community.
If you believe this issue is still relevant and requires attention, feel free to reopen it. Reopening the issue is a valuable signal to us about what matters most to you.
You can learn more about our approach and motivations in the Prisma ORM Manifesto.
With love,
Your Prisma ORM Team ❤️