Based on the knowledge sources provided, I can offer some guidance on how to handle your situation without resetting your database and losing data. This process is called "baselining" in Prisma terminology.
To avoid resetting your database and losing data when migrating from MySQL to PostgreSQL, you can follow these steps:
- Create an initial migration that represents your current database state without applying it:
mkdir -p prisma/migrations/init
npx prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > prisma/migrations/init/migration.sql
npx prisma migrate resolve --applied init
-
After this, run npx prisma migrate dev. It should indicate that everything is in sync.
-
You should also manually add a lock file in prisma/migrations/migration_lock.toml with the following content:
provider = "postgresql"
This approach allows you to baseline your existing PostgreSQL database without resetting it and losing data. It tells Prisma Migrate to assume that the initial migration has already been applied, so it won't try to create tables that already exist.
For more detailed information on baselining, you can refer to the Prisma documentation on baselining.
If you encounter any issues during this process or need further clarification, please don't hesitate to ask for more specific guidance.
Github Issue Comment