ERROR: column "filename" of relation "ActionDependencyList" contains null values
Sorry for the noob question but I am a bit confused what should I do after this error. Can someone help me please?
8 Replies
This is my model where I made some changes.
Output of migration.sql when I ran
npx prisma migrate dev
So, essentially what you're doing is adding the
filename
column along with other stuff (including a composite primary key)
Since you already have rows in your database, all of those rows are going to have null
for filename
(since you just added it)
But you've said that filename
cannot be null, so that's where you get there error.
To fix it you can either give the filename
field a default value, make it nullable, or remove all rows from your database 😆@Jon Harrell is there any other command do I have to run before npx prisma migrate?
And what I understood, I need to delete all records in my database where i ve some records, am I right?
Should I run
npx prisma reset
before the npx prisma migrate dev
?![No description](https://cdn.answeroverflow.com/1243663332079173652/image.png)
So, that's one option. I'm not sure if it's the one that I would take. It depends on your needs.
Here are the Prisma Migrate docs
Personally I would update your column to be nullable or to have a default value.
Prisma CLI reference | Prisma Documentation
This page gives an overview of all available Prisma CLI commands, explains their options and shows numerous usage examples.
Seems the column is not created btw.. Sorry for dump question but how should I update the column to be nullabable?
Personally I would update your column to be nullable or to have a default value.Shall I edit below part manually in migration.sql?
ADD COLUMN "filename" TEXT NOT NULL
Or run first
DELETE FROM public."ActionDependencyList";
and then run again npx prisma migrate dev
?The column isn't created because the migration failed. When a migration fails, nothing inside of it succeeds. So that's why that is happening.
Here's info on making a field optional
And here's info on defining a default value
Models | Prisma Documentation
Learn about the concepts for building your data model with Prisma: Models, scalar types, enums, attributes, functions, IDs, default values and more.
ok I deleted all the records and re-run the npx prisma migrate dev, where seems worked now