P
Prisma•2w ago
TJ

Empty migration when baselining a database

Hi I'm following this https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining to baseline a MariaDB database.
npx prisma migrate diff \
--from-empty \
--to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sql
npx prisma migrate diff \
--from-empty \
--to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sql
but the migration.sql is empty
-- This is an empty migration.
-- This is an empty migration.
What am I missing here?
Baselining a database | Prisma Documentation
How to initialize a migration history for an existing database that contains important data.
4 Replies
Prisma AI Help
Prisma AI Help•2w ago
You decided to hold for human wisdom. We'll chime in soon! Meanwhile, #ask-ai is there if you need a quick second opinion.
Nurul
Nurul•2w ago
Hmm! That's strange. Can you try running npx prisma db pull to ensure that your schema.prisma file is in sync with tables from your database?
TJ
TJOP•7d ago
Hi That is working after I ran pnpm prisma db pull. Here are the steps:
$ rm -fr prisma/migrations/
$ mkdir -p prisma/migrations/0_init
$ cat prisma/schema.prisma
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}

generator client {
provider = "prisma-client-js"
}

$ pnpm prisma db pull
$ pnpm prisma migrate diff \
--from-empty \
--to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sql
$ rm -fr prisma/migrations/
$ mkdir -p prisma/migrations/0_init
$ cat prisma/schema.prisma
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}

generator client {
provider = "prisma-client-js"
}

$ pnpm prisma db pull
$ pnpm prisma migrate diff \
--from-empty \
--to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sql
pnpm prisma db pull should be mentioned in the baselining documentation too?
Nurul
Nurul•7d ago
Glad to hear that it is working now! Doing db pull shouldn't be mandatory though 🤔

Did you find this page helpful?