prisma 2.20.1: migration create duplicate migration.sql to alter table
See original GitHub issueBug 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:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top 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 >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
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
Thanks for the update.