Let’s assume you are trying to seed your database using the seeding script and schema shown below.
index.ts
schema.ts
If the bloodPressure table has a not-null constraint on the userId column, running the seeding script will cause an error.
What does it mean?
This means we can’t fill the userId column with Null values due to the not-null constraint on that column.
Additionally, you didn’t expose the users table to the seed function schema, so we can’t generate users.id to populate the userId column with these values.
At this point, you have several options to resolve the error:
You can remove the not-null constraint from the userId column;
You can expose users table to seed function schema
By running the seeding script above you will see a warning
What does it mean?
This means you neither provided the users table to the seed function schema nor refined the userId column generator.
As a result, the userId column will be filled with Null values.
Then you will have two choices:
If you’re okay with filling the userId column with Null values, you can ignore the warning;
Otherwise, you can refine the userId column generator.
Refining the userId column generator
Doing so requires the users table to already have IDs such as 1 and 2 in the database.