prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
39.47k stars 1.54k forks source link

migrate diff doesn't work with fulltext index #18967

Open Rima-chan opened 1 year ago

Rima-chan commented 1 year ago

Bug description

I have added a fulltext index on a field of my table I ran the migration and it works as expected However, when i run the npx migrate diff (only from migrations to database), i have the following output

$ npx prisma migrate diff --from-migrations ./src/prisma/migrations --to-schema-datamodel ./src/prisma/schema.prisma --shadow-database-url $SHADOW_DATABASE_URL --script

-- DropIndex
DROP INDEX `Translation_fr_idx` ON `Translation`;
-- CreateIndex
CREATE FULLTEXT INDEX `Translation_fr_idx` ON `Translation`(`fr`);

Knowing that running this command outputs nothing :

$ npx prisma migrate diff --from-url mysql://root:password@localhost:3306/shadow --to-schema-datamodel ./src/prisma/schema.prisma

No difference detected.

So it seems that once migration is applied there is no difference between shadow database and datamodel.

I've also checked with MySQL, the type of my index which is a FULLTEXT Index :

image

I really don't understand why npx migrate diff detect differences and I can't investigate the migration-engine binary.

Thanks for your help and don't hesitate if feedback are missings

How to reproduce

Expected behavior

nxp prisma migrate diff should not detect differences between migrations files and prisma model

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fullTextSearch", "fullTextIndex"]
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model Translation {
  id String @id @default(uuid())
  fr String

  @@fulltext([fr])
}

Environment & setup

Prisma Version

prisma : 4.13.0
@prisma/client: 4.13.0
janpio commented 1 year ago

What does the migration file look like that added the full text index to the database?

Rima-chan commented 1 year ago

This is the migration file

CREATE TABLE `Translation` (
    `id` VARCHAR(191) NOT NULL,
    `fr` TEXT NOT NULL,

    FULLTEXT INDEX `Translation_fr_idx`(`fr`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;