This repository was archived by the owner on Aug 25, 2021. It is now read-only.
Description Bug description
Adding a new column with @default(cuid()) ends up with null values in the new column after migration.
How to reproduce
Add a new column to an existing table, e.g.:
model Folder {
...
uid String? @default(cuid())
...
}
Run prisma migrate save --experimental followed by prisma migrate up --experimental
Notes:
Tried with and without @unique and the result is the same
String? type is required as String crashes the migration. Not sure why. It would be preferred that the column would be mandatory.
Edit:
With String as the type, the migration fails on the following error, which is also described in #527:
Added the required column X to the Y table without a default value. There are N rows in this table, it is not possible to execute this migration.
Expected behavior
The Folder table should contain a new uid column with generated cuid values.
Prisma information
N/A
Environment & setup
OS: Mac OS
Database: PostgreSQL
Node.js version: v12.18.3
Prisma version:
@prisma/cli : 2.5.1
Current platform : darwin
Query Engine : query-engine c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/query-engine-darwin)
Migration Engine : migration-engine-cli c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary : prisma-fmt c88925ce44a9b89b4351aec85ba6a28979d2658e (at node_modules/@prisma/cli/prisma-fmt-darwin)
Studio : 0.261.0
Reactions are currently unavailable
Bug description
Adding a new column with
@default(cuid())ends up with null values in the new column after migration.How to reproduce
Add a new column to an existing table, e.g.:
Run
prisma migrate save --experimentalfollowed byprisma migrate up --experimentalNotes:
@uniqueand the result is the sameString?type is required asStringcrashes the migration. Not sure why. It would be preferred that the column would be mandatory.Edit:
With
Stringas the type, the migration fails on the following error, which is also described in #527:Expected behavior
The
Foldertable should contain a newuidcolumn with generatedcuidvalues.Prisma information
N/A
Environment & setup