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

Float cause duplicate alter table in all migrations #14052

Closed
ingbond opened this issue Jun 29, 2022 · 1 comment · Fixed by prisma/prisma-engines#3066
Closed

Float cause duplicate alter table in all migrations #14052

ingbond opened this issue Jun 29, 2022 · 1 comment · Fixed by prisma/prisma-engines#3066
Assignees
Labels
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. tech/engines/migration engine Issue in the Migration Engine topic: migrate topic: sql server Microsoft SQL Server
Milestone

Comments

@ingbond
Copy link

ingbond commented Jun 29, 2022

Bug description

I have such model

model Logbook {
  meter    Float?          @db.Float
  interval Float?          @db.Float
}

After I added these float fields, all my future migrations contains 'ALTER TABLE' for that:

ALTER TABLE [dbo].[Logbook] ALTER COLUMN [meter] FLOAT NULL;
ALTER TABLE [dbo].[Logbook] ALTER COLUMN [interval] FLOAT NULL;

How to reproduce

  1. Use sql server
  2. Add float fields to your model
  3. Create migration

Expected behavior

Do change table only once

Prisma information

model Logbook {
  id             String          @id(map: "PK_Logbook") @default(uuid()) @db.UniqueIdentifier
  title          String          @db.NVarChar(50)
  description    String?          @db.NVarChar(Max)
  meter          Float?          @db.Float
  interval       Float?          @db.Float
  date           DateTime        @db.Date()
  modified       DateTime        @default(now()) @db.DateTime()
}

Environment & setup

OS: Windows
Database: Sql Server
Node.js version: 16.15.1

Prisma Version

3.15.1
@ingbond ingbond added the kind/bug A reported bug. label Jun 29, 2022
@tomhoule tomhoule added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. process/candidate team/schema Issue for team Schema. tech/engines/migration engine Issue in the Migration Engine labels Jun 29, 2022
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 14, 2022
We weren't properly handling the implicit precision: we sent FLOAT, got
back FLOAT(53), and interpreted that as different types, but they're the
same.

closes prisma/prisma#14052
@tomhoule tomhoule self-assigned this Jul 14, 2022
@tomhoule
Copy link
Contributor

I could reproduce the problem in tests and identified the cause — it will be fixed by prisma/prisma-engines#3066, which will be in the next Prisma release (4.1). As a workaround in the meantime, you can replace @db.Float with @db.Float(53) to avoid the spurious migrations. Thanks for reporting this bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. tech/engines/migration engine Issue in the Migration Engine topic: migrate topic: sql server Microsoft SQL Server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants