#11778·Prisma

Migration failed with error table doesn't exist but table exists

Author: adrien-guesnelCreated Feb 12, 2022Updated Sep 29, 2026
Labelsbug/1-unconfirmedkind/bugtopic: migratetech/enginestopic: prisma migrate dev

Bug description

Hi,

I would like to drop a column with a migration but an error happened that said the table doesn't exist. But the table exists because I can put the column optional for a workaround.

Complete error :

Error: P3018

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: https://pris.ly/d/migrate-resolve

Migration name: 20220212191040_drop

Database error code: 1146

Database error:
Table 'westies-babies.dancelesson' doesn't exist

Please check the query number 1 from the migration file.

The migration created for the drop that doesn't work ❌:

/*
  Warnings:

  - You are about to drop the column `level` on the `DanceLesson` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE `DanceLesson` DROP COLUMN `level`; 

The migration to put the column optional that works ✅ :

-- AlterTable
ALTER TABLE `DanceLesson` MODIFY `level` INTEGER NULL DEFAULT 0;

Thanks for you help

How to reproduce

  1. Try to delete level line from the model
  2. Generate the migration => error when apply

Expected behavior

Drop the column without error

Prisma information

model DanceLesson {
  id            Int                   @id @default(autoincrement())
  createdAt     DateTime              @default(now())
  updatedAt     DateTime              @updatedAt
  danceSchoolId Int
  level Int
  name String
  danceSchool   DanceSchool           @relation(fields: [danceSchoolId], references: [id], onDelete: Cascade, map: "dancelesson_ibfk_1")

  @@index([danceSchoolId], map: "danceSchoolId")
}

Environment & setup

OS: Mac Os v12.1 Database: Mysql v5.7 Node.js version: v16.13.2

Prisma Version

prisma                  : 3.7.0
@prisma/client          : 3.7.0
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules/prisma/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules/prisma/node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules/prisma/node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash    : 8746e055198f517658c08a0c426c7eec87f5a85f
Studio                  : 0.445.0