Hi folks. I'm migrating from TypeORM and running `...
# orm-help
g
Hi folks. I'm migrating from TypeORM and running
prisma migrate dev --create-only
, Prisma asks me to reset the database in dev. Why is this happening?
j
Hi Gezim! so
prisma migrate dev
(and --create-only) will check things like migrations missing from your migrations folder but already applied to the dev database, or migrations that were modified since they were applied (via a checksum) and guide you towards resolving the problem (the reset).
Do you have more details about what you are trying to do? I can recommend this page https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/add-prisma-migrate-to-a-project
g
I’m trying to move from TypeORM to Prisma, really. The db tables exists. I did a
prisma db pull
just prior to attempting the
prisma migrate dev…
command. In the
prisma
folder I only have
schema.prisma
. There isn’t a prisma migration table in the database either.
Thanks for your response @Joël 🙏
I appreciate any help I can get
j
Then this page sounds like it fits very well your case
As part of adding Prisma Migrate to your development environment, you must reset your development database. This will result in data loss in the development database only.
Let me know if you need help after reading it
g
This will result in data loss in the development database only.
How does that work? How will it know not to run that “initial” migration in prod?
Hi @Joël, I’m not able to make sense o this error that I get when I try to run
prisma migrate dev
from the above guide:
Copy code
Error: P3006

Migration `20220104035918_initial_migration` failed to apply cleanly to the shadow database.
Error:
db error: ERROR: type "e" does not exist
   0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
             at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:367
   1: sql_migration_connector::validate_migrations
             at migration-engine/connectors/sql-migration-connector/src/lib.rs:351
   2: migration_core::api::DevDiagnostic
             at migration-engine/core/src/api.rs:108
I had to modify the initial migration to add this line
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
I’m not sure what happened but using
npx prisma migrate dev
and trying a bunch of times (instead of
prisma migrate dev
) fixed it
j
Ok good it worked in the end but a bit weird 🤔
And about
How does that work? How will it know not to run that “initial” migration in prod?
It’s explained in the baseline step https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/add-prisma-migrate-to-a-project#baseline-your-production-environment
🙏 1