Problem/Motivation

Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value: INSERT INTO "block_content" ("revision_id", "type", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => basic [:db_insert_placeholder_2] => f6a5803b-9ef7-4941-a0db-6df8916eaa19 [:db_insert_placeholder_3] => it ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (linea 815 di /home/********/website/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Steps to reproduce

Upgraded website from Drupal 8.9.20 to Drupal 9.5.9

Anyone who had faced same issue?

Comments

Niubbo75 created an issue. See original summary.

cilefen’s picture

The site probably missed a schema update.

Niubbo75’s picture

@cilefen how can I upgrade schema?
Thanks for your reply.

catch’s picture

@Niubbo75 this means running updates - either from update.php, or drush updb.

Niubbo75’s picture

@catch done yet, but nothing to update.

Niubbo75’s picture

Solved, I manually add keys that were lost, now seems that all works.
I use another DB of another installation that work to compare tables and keys.
Best regards,
Alessandro

Niubbo75’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

devkinetic’s picture

I ran into this as well on a recent upgrade from Drupal 8 -> 9 -> 10. We ended up having to do a full database audit and found multiple issues, Before doing so we attempted the entire upgrade again so there is absolutely something missing in the upgrade path:

  • batch table
    • missing primary keys
    • missing indexes
    • missing auto increment on bid
  • block_content table
    • missing primary keys
    • missing indexes
    • missing auto increment on id
  • block_content_* tables
    • missing primary keys
    • missing indexes
  • some cache_* tables
    • missing primary keys
    • missing indexes
  • users table
    • missing auto increment on uid

We solved the issue with the audit, and fixing the schema manually. I saw the referenced error about the users table, and can confirm that that update was ran but didn't fix things. I guess something to look out for when upgrading!