question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prisma 2.20.1: migration create duplicate migration.sql to alter table

See original GitHub issue

Bug description

With version 2.20.1 prisma migrate dev generate duplicate migration.sql files to alter tables if enums with default value are used in schema.prisma.

How to reproduce

clone https://github.com/mazzaker/prisma_migrate_issue You need a local mysql and change the URL string in prisma.schema file. use yarn/npm initDb a new migration will be created, the same sql as the migration files added before.

Expected behavior

I think an empty migration file is the default behavior.

Prisma information

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

datasource db {
  provider = "mysql"
  url      = "mysql://root:@127.0.0.1:3306/testPrismaMigrate"
}

enum Role {
  Guest
  Incomplete
  Blocked
  Deleted
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
  role  Role    @default(Guest)
}

model Post {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String
  content   String?
  published Boolean  @default(false)
  viewCount Int      @default(0)
  author    User?    @relation(fields: [authorId], references: [id])
  authorId  Int?
}

Environment & setup

  • OS: Windows 10 Pro with WSL 2 Debian 10.8
  • Database: mysql Ver 15.1 Distrib 10.1.38-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
  • Node.js version: 14.7.0
  • Prisma version: 2.20.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Bjoernstjernecommented, Dec 1, 2021

Sorry for the late response, this issue happened with an older version of mariaDb I do not know the version anymore but did not raised with version: mariadb Ver 15.1 Distrib 10.5.12-MariaDB

0reactions
janpiocommented, Dec 1, 2021

Thanks for the update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 dev...
Read more >
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 >
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 >
Developing with Prisma Migrate
Creates a ./prisma/migrations folder with your initial migration: migrations/. └─ 20210305110829_first_migration/. └─ migration.sql · Creates a table named ...
Read more >
Prisma 2.17.0 Release - GitClear
Database resets in the context of Prisma Migrate now gracefully fall back to dropping constraints, indexes and tables, if there are insufficient ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found