Sitemap

How to Reset Your PostgreSQL Database Using Prisma in Early Development

2 min readApr 4, 2025

--

Press enter or click to view image in full size
Photo by Emile Perron on Unsplash

During the early stages of development, you may frequently need to reset your database to reflect schema changes, especially when modifying models, relationships, or other structures.

When you make changes to your schema.prisma file (e.g., adding a new model or changing a field type), you need to generate and apply migrations to keep the database schema in sync with your code.

Normally, you would run the command:

npx prisma migrate reset --force

This should be sufficient, but recently, I encountered an error that I shouldn’t have had to deal with during early development:

The table `public.Role` does not exist in the current database.

Prisma provides tools to manage migrations, but sometimes it’s useful to start fresh to ensure that your schema is applied correctly and to avoid unnecessary errors.

Here’s a quick guide on how to reset your database and apply the current schema using Prisma without errors.

Resetting and Starting Fresh

If you want to completely start fresh (e.g., during early development) without keeping old migrations, you can delete the migrations folder and reapply migrations as follows:

1. Delete the migrations folder

rm -rf prisma/migrations

This removes any existing migration files.

2. Force migration reset while skipping seed if available

Reset the database to match the current schema.

npx prisma migrate reset --force --skip-seed

3. Generate a new migration

npx prisma migrate dev --name init

This generates a new migration based on the current state of your schema.prisma file. The --name init flag creates an initial migration.

4. Reset the database

npx prisma migrate reset --force

This drops all tables and applies the newly generated migration.

Get Daniel Ayia’s stories in your inbox

Join Medium for free to get updates from this writer.

This approach will:

  • Remove old migration files.
  • Generate and apply a fresh migration.
  • Reset the database to match the current schema.

Using a Custom Script

To simplify the reset process, you can create a custom script:

"reset-db": "rm -rf prisma/migrations && npx prisma migrate dev --name init && npx prisma migrate reset --force"

Running the Script

Once the script is defined in your package.json, you can run it with:

npm run reset-db

Note: This approach clears all data in the database. It is suitable for development but should not be used in production.

--

--

Daniel Ayia
Daniel Ayia

Practical awareness for builders.