PDOException: SQLSTATE[HY000]: General error: 1364 Field 'bid' doesn't have a default value trying to create/enable a block

Have a large site set up running Drupal 7 with several hundred nodes, many views, blocks, etc.

In October last year the hosting provider moved everything to a new server and after that strange things started happening, with several D7 sites being of limited usability, they had to be repaired.

Towards the end of 2018 I’ve had problems with people being unable to post comments, error message was very similar to the above, except insted of the ‘bid’ the reported error was with the ‘cid’ field (comment table).

And now, if I try creating a new block or modify and try saving an existing block, I get an error, saying that an unexpected error had occured, please try again later.

In Drupal’s log the below event is logged:
PDOException: SQLSTATE[HY000]: General error: 1364 Field ‘bid’ doesn’t have a default value: INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => views [:db_insert_placeholder_1] => gradiva_seminarjev_2019-block_1 [:db_insert_placeholder_2] => sir [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => -1 [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => -1 ) in drupal_write_record() (line 7396 of /var/www/vhosts/si-revizija.si/httpdocs/includes/common.inc).

Sometimes saving a block works right after clearing caches, but as soon as I try repositioning it, it is gone again.

Could it be that this has something to do with views, since some of the blocks that I tried repositioning lately are generated by a view?

I have seen suggestions to create a new database, install Drupal, install these same modules, and then import the old database (without structure, at least for the block and comment table) into the new one.

I am afraid that the above solution may not be the right one and thererfore am looking for options to mend the existing database.

Would running the following SQL command help: ALTER TABLE node MODIFY COLUMN bid VARCHAR(255) NOT NULL DEFAULT ”
Found this at https://www.drupal.org/node/1428176

Also, Drush is not in use.

Of course I did check for updates, all are installed, caches cleared, etc.

Please help 🙂

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/22/feed