When to use hook_update_N & hook_post_update_NAME?
Karthik Kumar D K, Feb 8, 2022
https://peoplesblog.co.in/articles/when-to-use-hook_update_n-and-hook_post_update_name.html
Change field type with existing data on Drupal 8
Luis Gerzenstein, April 24, 2019
https://blog.42mate.com/change-field-type-with-existing-data-on-drupal-8/
A example of using hook_update for changing entities in the database.
When writing hooks or investigating failed database updates it’s useful viewing and setting/resetting schema versions.
drush ev 'print \Drupal::keyValue("system.schema")->get("the_module") . "\n";'
drush ev "\Drupal::keyValue('system.schema')->set('the_module', (int) 8102)";
// GET
$ver = drupal_get_installed_schema_version('moduleName');
$ver = \Drupal::keyValue("system.schema")->get("moduleName");
//SET
drupal_set_installed_schema_version("moduleName", "8000");
\Drupal::keyValue('system.schema')->set('moduleName', (int) 8102);