Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_storage_update_field.twig
1 /**
2  * Implements hook_field_storage_update_field().
3  */
4 function {{ machine_name }}_field_storage_update_field($field, $prior_field, $has_data) {
5   if (!$has_data) {
6     // There is no data. Re-create the tables completely.
7     $prior_schema = _field_sql_storage_schema($prior_field);
8     foreach ($prior_schema as $name => $table) {
9       db_drop_table($name, $table);
10     }
11     $schema = _field_sql_storage_schema($field);
12     foreach ($schema as $name => $table) {
13       db_create_table($name, $table);
14     }
15   }
16   else {
17     // There is data. See field_sql_storage_field_storage_update_field() for
18     // an example of what to do to modify the schema in place, preserving the
19     // old data as much as possible.
20   }
21   drupal_get_schema(NULL, TRUE);
22 }