Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prisma migrate reset always exits with 0, needs to exit with 1 on errors #9786

Closed
ryanflorence opened this issue Oct 14, 2021 · 0 comments · Fixed by #13223
Closed

prisma migrate reset always exits with 0, needs to exit with 1 on errors #9786

ryanflorence opened this issue Oct 14, 2021 · 0 comments · Fixed by #13223
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/typescript Issue for tech TypeScript. topic: cli topic: prisma db seed CLI: prisma db seed topic: prisma migrate reset CLI: prisma migrate reset
Milestone

Comments

@ryanflorence
Copy link

ryanflorence commented Oct 14, 2021

Bug description

If your seed script throws an error, prisma's shell exit code is still 0, which is especially problematic for CI that might be deploying a newly seeded DB.

How to reproduce

write a seed script that just throws an error

throw new Error("oops");

Then in the prompt:

prisma migrate reset --force
echo $?
# 0

Note that prisma db seed exits properly

prisma db seed
echo $?
# 1

Expected behavior

It should exit with 1 for errors, just like prisma db seed.

prisma migrate reset --force
echo $?
# 1

Prisma information

n/a

Environment & setup

sqlite
macOS and github actions linux

Prisma Version

prisma                  : 3.1.1
@prisma/client          : 3.1.1

Workaround

Don't use the cli, make your own script:

import { Migrate } from "@prisma/migrate";

async function seed() {
  // whatever ...
}

async function go() {
  let migrate = new Migrate();
  try {
    await migrate.reset();
    await seed();
  } catch (e) {
    throw e;
  }
}

go();
@ryanflorence ryanflorence added the kind/bug A reported bug. label Oct 14, 2021
@janpio janpio added the topic: prisma db seed CLI: prisma db seed label Oct 14, 2021
@janpio janpio added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. team/schema Issue for team Schema. topic: prisma migrate reset CLI: prisma migrate reset labels Nov 19, 2021
@janpio janpio added tech/typescript Issue for tech TypeScript. and removed process/candidate labels Jan 12, 2022
@Jolg42 Jolg42 self-assigned this Jan 24, 2022
@Jolg42 Jolg42 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Feb 8, 2022
@Jolg42 Jolg42 added this to the 3.12.0 milestone Mar 16, 2022
@Jolg42 Jolg42 modified the milestones: 3.12.0, 3.13.0 Apr 8, 2022
@Jolg42 Jolg42 modified the milestones: 3.13.0, 3.14.0 May 2, 2022
@Jolg42 Jolg42 modified the milestones: 3.14.0, 3.15.0 May 10, 2022
jkomyno added a commit that referenced this issue Jun 7, 2022
* fix(migrate reset): exit 1 if an error happens during seeding

Closes #9786

* migrate: added TODO comments

* [skip ci] Removed TODO in favor of issue #13355

Co-authored-by: Alberto Schiabel <skiabo97@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/typescript Issue for tech TypeScript. topic: cli topic: prisma db seed CLI: prisma db seed topic: prisma migrate reset CLI: prisma migrate reset
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants