title: Prisma migration is bad state
body: <p>We seem to have gotten our prisma migrations into a bad state. When we get the latest code and run</p>
  <pre><code>prisma migrate dev
  </code></pre>
  <p>we get</p>
  <blockquote>
  <p>Migration <code>20210819161149_some_migration</code> failed to apply cleanly to
  the shadow database.  Error code: P3018 Error: A migration failed to
  apply. New migrations cannot be applied before the error is recovered
  from. Read more about how to resolve migration issues in a production
  database: <a href="https://pris.ly/d/migrate-resolve" rel="nofollow noreferrer">https://pris.ly/d/migrate-resolve</a></p>
  <p>Migration name: 20210819161149_some_migration</p>
  <p>Database error code: 1065</p>
  </blockquote>
  <p>All the migrations in source control do match the ones in the <code>_prisma_migrations</code> table so I'm not sure why it thinks <code>20210819161149_some_migration</code> failed. There is nothing in the <code>logs</code> column in <code>_prisma_migrations</code> for that record. I think what happened is a developer applied the migration then changed the <code>migration.sql</code> for it after the fact.</p>
  <p>Anyway, we followed the steps outlined <a href="https://pris.ly/d/migrate-resolve" rel="nofollow noreferrer">https://pris.ly/d/migrate-resolve</a> but they don't seem to resolve the issue. It first suggests running</p>
  <pre><code>prisma migrate resolve --rolled-back &quot;20210819161149_some_migration&quot;
  </code></pre>
  <p>but that results in</p>
  <blockquote>
  <p>Error: P3012</p>
  <p>Migration <code>20210819161149_some_migration</code> cannot be rolled
  back because it is not in a failed state.</p>
  </blockquote>
  <p>So then we tried to mark it as applied</p>
  <pre><code>prisma migrate resolve --applied &quot;20210819161149_some_migration&quot;
  </code></pre>
  <p>but that results in this error</p>
  <blockquote>
  <p>Error: P3008</p>
  <p>The migration <code>20210819161149_some_migration</code> is already
  recorded as applied in the database.</p>
  </blockquote>
  <p>We also tried running</p>
  <pre><code> prisma migrate deploy
  </code></pre>
  <p>Which gives</p>
  <blockquote>
  <p>13 migrations found in prisma/migrations WARNING The following
  migrations have been modified since they were applied:
  20210819161149_some_migration</p>
  </blockquote>
  <p>but you still get the same issue above when running <code>prisma migrate dev</code>.</p>
  <p>Is there any way to get prisma happy again without deleting all the data?</p>