Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate: @dbgenerated with @db.Time(0) keeps generating new migrations #6382

Closed
daniellwdb opened this issue Apr 2, 2021 · 3 comments · Fixed by prisma/prisma-engines#3515
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines Issue for tech Engines. topic: dates / DateTime topic: @db.Time Native type `Time` topic: dbgenerated topic: endless migrations topic: mysql topic: prisma migrate dev CLI: prisma migrate dev
Milestone

Comments

@daniellwdb
Copy link

daniellwdb commented Apr 2, 2021

Bug description

Whenever you use a schema field decorated with DateTime @default(dbgenerated("\"00:00:00\"")) @db.Time(0) and run npx prisma migrate dev, you are asked for a new migration name but the generated migration is always the same

How to reproduce

Create a model

model A {
  id      Int       @id @default(autoincrement()) @db.UnsignedInt
  from    DateTime  @default(dbgenerated("\"00:00:00\"")) @db.Time(0)
}

Run npx prisma migrate dev, after that another time, it keeps asking for a new migration name

Expected behavior

There should be no prompt for a new migration since the output is always the same

Environment & setup

  • OS: Windows (WSL2, Ubuntu 20.04)
  • Database: MySQL 8
  • Node.js version: v15.12.0
  • Prisma version:
prisma               : 2.20.1
@prisma/client       : 2.20.1
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 60ba6551f29b17d7d6ce479e5733c70d9c00860e
Studio               : 0.365.0
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: prisma migrate dev CLI: prisma migrate dev labels Apr 2, 2021
@tomhoule
Copy link
Contributor

tomhoule commented Apr 6, 2021

Thanks for reporting this! We'll work on it as soon as possible.

@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Apr 19, 2021
@janpio janpio changed the title Migrate: @dbgenerated with @db.Time(0) keeps asking for new migration name Migrate: @dbgenerated with @db.Time(0) keeps generating new migrations Dec 8, 2021
@Jolg42 Jolg42 removed the topic: diff label Feb 2, 2022
@janpio janpio added the tech/engines Issue for tech Engines. label Mar 24, 2022
@pimeys pimeys added this to the 4.8.0 milestone Dec 15, 2022
@simonv3
Copy link

simonv3 commented Nov 28, 2023

I'm still seeing this in prisma 5

The schema line:

  emailConfirmationExpiration         DateTime?                @default(dbgenerated("NOW() + interval '10 min'"))

and the generated migration

-- AlterTable
ALTER TABLE "User" ALTER COLUMN "emailConfirmationExpiration" SET DEFAULT NOW() + interval '10 min';

Is included in every migration and also creates a migration if there are no other changes

@janpio
Copy link
Member

janpio commented Jan 16, 2024

Open a new issue then please and include all the information the issue template asks for. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines Issue for tech Engines. topic: dates / DateTime topic: @db.Time Native type `Time` topic: dbgenerated topic: endless migrations topic: mysql topic: prisma migrate dev CLI: prisma migrate dev
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants