Unwanted migration generate every time running `prisma migrate dev` with edited migration file that enables Postgres extensions
See original GitHub issueBug description
In my project, I need to use UUID on the db side and so I followed this guide and edited the file as
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- Added this only
-- CreateTable
CREATE TABLE "accounts" (
"id" UUID NOT NULL DEFAULT public.uuid_generate_v4(),
CONSTRAINT "accounts_pkey" PRIMARY KEY ("id")
);
Then every time when I run prisma migrate dev
, it prompts me to create a new migration. But the migration is doing nothing:
-- AlterTable
ALTER TABLE "accounts" ALTER COLUMN "id" SET DEFAULT public.uuid_generate_v4();
How to reproduce
- run
prisma migrate dev --create-only
- add
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
to the first line of the generated file prisma migrate status
correctly givesDatabase schema is up to date!
- run
prisma migrate dev
, then it prompts✔ Enter a name for the new migration:
Expected behavior
Should correctly detects the schema is up to date and no new migration is needed
Prisma information
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Account {
id String @id @default(dbgenerated("public.uuid_generate_v4()")) @db.Uuid()
@@map("accounts")
}
Environment & setup
- OS: macOS 12.1
- Database: Postgres
- Node.js version: v16.13.0
Prisma Version
prisma : 3.10.0
@prisma/client : 3.10.0
Current platform : darwin
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio : 0.458.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Prisma Migrate | Database, Schema, SQL Migration Tool
Prisma Migrate is a database migration tool available via the Prisma CLI that integrates with Prisma schema for data modeling.
Read more >Migration troubleshooting in development - Prisma
This guide describes how to resolve issues with Prisma Migrate in a development environment, which often involves resetting your database.
Read more >Squashing migrations - Prisma
This guide describes how to squash multiple migration files into a single migration. About squashing migrations. It is sometimes useful to squash either ......
Read more >Adding Prisma Migrate to an existing project
Check out a copy of the repository with the new migration directory and the schema.prisma file · Run the following command to reset...
Read more >Customize a migration file - Prisma
Make a schema change that requires custom SQL (for example, to preserve existing data) · Create a draft migration using: $npx prisma migrate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any updates? It happens on me after updating version to 4.6.0 from 3.0.1.
schema
migration
Happening for me as well.