Skip to content

prisma db reset that resets the database, pushes the schema, and runs the seed function #11261

@athyuttamre

Description

@athyuttamre

Problem

In the early stages of developing a new project, I find myself often repeating the following steps:

  1. Reset the database, using psql and drop database <db_name>
  2. Push the new schema and regenerate the client, using npx prisma db push
  3. Run the seed function, using npx prisma db seed

In effect, I want to start from a clean slate with my seed data and new schema, and re-run my app. I wish this was easier to do in one command.

Suggested solution

I want a command like prisma db reset that does the steps above: resets the database, pushes the new schema, regenerates the client, and runs the seed function.

Alternatives

I looked at npx prisma db push --force-reset which does steps 1 and 2, but it doesn't run the seed function.

I looked at npx prisma migrate reset but that doesn't push the schema to the database and instead tries to run migrations, which I don't use in the early stages of a product.

I ended up doing the steps manually each time. I suppose I could write my own npm script to do this, but it would be nice to use it with prisma directly since I'm used to using the prisma CLI commands.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions