P
Prisma•2w ago
zaloster

Migrations taking too long

Hi, I'm rewriting this since I think I may have written in the wrong channel, sorry. I've followed the instruction to create a baseline migration as shown here: https://www.prisma.io/docs/orm/prisma-migrate/getting-started This works good but now when I try to create a new migration it takes forever (~15 mins) to run (pnpm exec prisma migrate dev --name testing) I have to say that the database is around 70 tables and is running in a docker container using the official mysql image. Info regarding Prisma:
prisma : 5.21.1
@prisma/client : 5.21.1
Computed binaryTarget : linux-musl-openssl-3.0.x
Operating System : linux
Architecture : x64
Node.js : v20.18.0
Query Engine (Node-API) : libquery-engine bf0e5e8a04cada8225617067eaa03d041e2bba36 (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/libquery_engine-linux-musl-openssl-3.0.x.so.node)
Schema Engine : schema-engine-cli bf0e5e8a04cada8225617067eaa03d041e2bba36 (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/schema-engine-linux-musl-openssl-3.0.x)
Schema Wasm : @prisma/prisma-schema-wasm 5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36
Default Engines Hash : bf0e5e8a04cada8225617067eaa03d041e2bba36
Studio : 0.503.0
Preview Features : relationJoins, prismaSchemaFolder
prisma : 5.21.1
@prisma/client : 5.21.1
Computed binaryTarget : linux-musl-openssl-3.0.x
Operating System : linux
Architecture : x64
Node.js : v20.18.0
Query Engine (Node-API) : libquery-engine bf0e5e8a04cada8225617067eaa03d041e2bba36 (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/libquery_engine-linux-musl-openssl-3.0.x.so.node)
Schema Engine : schema-engine-cli bf0e5e8a04cada8225617067eaa03d041e2bba36 (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/schema-engine-linux-musl-openssl-3.0.x)
Schema Wasm : @prisma/prisma-schema-wasm 5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36
Default Engines Hash : bf0e5e8a04cada8225617067eaa03d041e2bba36
Studio : 0.503.0
Preview Features : relationJoins, prismaSchemaFolder
Attached additional screenshot. Thank you very much
Getting started with Prisma Migrate | Prisma Documentation
Learn how to migrate your schema in a development environment using Prisma Migrate.
No description
7 Replies
Nurul
Nurul•2w ago
Hello @zaloster 👋 Have you tried squashing your migrations? It should be helpful in reducing the time taken for generating a new migration https://www.prisma.io/docs/orm/prisma-migrate/workflows/squashing-migrations#creating-a-clean-history-in-a-production-environment
Squashing migrations | Prisma Documentation
How to squash multiple migration files into a single migration
zaloster
zalosterOP•2w ago
hi Nurul, thanks for replying. The thing is that there is not mucha to squash. There is only the initial sql file with the 70 table schemas.
Nurul
Nurul•2w ago
Oh! I thought you had a long list of migrations which might be causing this delay.
zaloster
zalosterOP•2w ago
that one was resolved using npx prisma migrate resolve --applied 0_init no, just starting using it with an existing database
Nurul
Nurul•2w ago
I was able to find a related GitHub Issue: https://github.com/prisma/prisma/issues/22092 I believe you are reporting the same behaviour
GitHub
prisma migrate dev very slow even after squash of migrations · Is...
Bug description Hi we have a fairly large model (~150 tables & ~1800 columns) and we decided to squash our migrations in the hope of having some speed improvements. But still the the prisma mig...
Nurul
Nurul•2w ago
Can you run this command and share the time you are observing?
DEBUG="prisma:migrate*" npx prisma migrate dev --skip-generate
DEBUG="prisma:migrate*" npx prisma migrate dev --skip-generate
zaloster
zalosterOP•2w ago
Environment variables loaded from .env
Prisma schema loaded from prisma/schema
Datasource "db": MySQL database "database-wa" at "host.docker.internal:3306"

prisma:migrate:dev {
"devDiagnostic": "{\n \"action\": {\n \"tag\": \"reset\",\n \"reason\": \"Drift detected: Your database schema is not in sync with your migration history.\\n\\nThe following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.\\n\\nIt should be understood as the set of changes to get from the expected schema to the actual schema.\\n\\n[+] Added tables\\n - flyway_schema_history\\n\"\n }\n}"
} +418385ms
Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

[+] Added tables
- flyway_schema_history

? We need to reset the MySQL database "database-wa" at "host.docker.internal:3306"
Do you want to continue? All data will be lost. › (y/N)
Environment variables loaded from .env
Prisma schema loaded from prisma/schema
Datasource "db": MySQL database "database-wa" at "host.docker.internal:3306"

prisma:migrate:dev {
"devDiagnostic": "{\n \"action\": {\n \"tag\": \"reset\",\n \"reason\": \"Drift detected: Your database schema is not in sync with your migration history.\\n\\nThe following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.\\n\\nIt should be understood as the set of changes to get from the expected schema to the actual schema.\\n\\n[+] Added tables\\n - flyway_schema_history\\n\"\n }\n}"
} +418385ms
Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

[+] Added tables
- flyway_schema_history

? We need to reset the MySQL database "database-wa" at "host.docker.internal:3306"
Do you want to continue? All data will be lost. › (y/N)
This is the output DEBUG="prisma:migrate*" pnpm exec prisma migrate dev --skip-generate Using pnpm just in case it matters
Want results from more Discord servers?
Add your server