Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As #2183231: Make ContentEntityDatabaseStorage generate static database schemas for content entities and #2232477: Fatal when adding new fields with NOT NULL constraints in a base table that contains existing entities have shown, we've quite some fields with "not null" indexes that are not marked as required. Let's go through all "not null" indexes as defined by #2183231: Make ContentEntityDatabaseStorage generate static database schemas for content entities and mark the respective fields as required.
Comment | File | Size | Author |
---|---|---|---|
#4 | d8_required.patch | 9.4 KB | fago |
#3 | d8_required.patch | 10.53 KB | fago |
Comments
Comment #1
fagoActually, this is a bug. Thus re-phrasing.
Comment #2
BerdirStill an issue? Is this a duplicate of others that we fixed?
Comment #3
fagoI don't think this is an duplicate, as #2232477: Fatal when adding new fields with NOT NULL constraints in a base table that contains existing entities only deals with 'required' for property definitions. But there is no required flag for lots of base fields which have a default value and are actually required, as the API and schema relies on a non NULL value to be there.
We can find base fields by that by looking at the schema - everything that is not null should be required imo. Then, there are more fields which have default values and code that relies on them being not null: langcode, created, changed and more fields with explicitly defined default values. I shortly look over Comment, Node, Term, User entities and figured it should be something like the following patch.
Also, we should be able to auto-generate not-null schema information once we've the required property information fixed by #2232477: Fatal when adding new fields with NOT NULL constraints in a base table that contains existing entities.
Comment #4
fagosry for the unrelated hunks, re-rolled patch.
Comment #7
plachComment #8
mgiffordJust unassigning issues that haven't been developed for a bit in the D8 queue.
Comment #11
BerdirRelated #2390495: Support marking field storage definitions as required?
Comment #13
xjmThe entity and field maintainers discussed this issue with the core committers awhile back, and identified that this issue can be considered a duplicate of #2346019: Handle initial values when creating a new field storage definition,