After upgrade from 8.9.20 to 9.5.9 can't create custom block

Created on 6 June 2023, about 1 year ago
Updated 27 February 2024, 4 months ago

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?

💬 Support request
Status

Fixed

Version

9.5

Component
Database  →

Last updated 15 minutes ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇮🇹Italy Niubbo75

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Niubbo75
  • 🇺🇸United States cilefen

    The site probably missed a schema update.

  • 🇮🇹Italy Niubbo75

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

  • 🇬🇧United Kingdom catch

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

  • 🇮🇹Italy Niubbo75

    @cilefen done yet, but nothing to update.

  • 🇮🇹Italy Niubbo75

    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

  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 4 months ago
  • 🇺🇸United States devkinetic

    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!

Production build 0.69.0 2024