diff --git a/modules/islandora_core_feature/config/install/field.storage.media.field_file_size.yml b/modules/islandora_core_feature/config/install/field.storage.media.field_file_size.yml index 5c3e67c4..fff956db 100644 --- a/modules/islandora_core_feature/config/install/field.storage.media.field_file_size.yml +++ b/modules/islandora_core_feature/config/install/field.storage.media.field_file_size.yml @@ -11,8 +11,8 @@ field_name: field_file_size entity_type: media type: integer settings: - unsigned: false - size: normal + unsigned: true + size: big module: core locked: false cardinality: 1 diff --git a/modules/islandora_core_feature/islandora_core_feature.install b/modules/islandora_core_feature/islandora_core_feature.install new file mode 100644 index 00000000..6dd19fd0 --- /dev/null +++ b/modules/islandora_core_feature/islandora_core_feature.install @@ -0,0 +1,67 @@ +get($storage_key); + + foreach (["{$entity_type}__{$field_name}", "{$entity_type}_revision__{$field_name}"] as $table) { + // Squirrel away the data. + $data[$table] = $database->select($table, 'n') + ->fields('n') + ->execute() + ->fetchAll(); + + // Clean it out for resizing. + $database->truncate($table)->execute(); + $database->schema()->dropPrimaryKey($table); + + // Resize the main field data table. + $database->query("ALTER TABLE $table MODIFY {$field_name}_value BIGINT(11) unsigned NOT NULL"); + + // Update storage schema. + $field_schema[$table]['fields'][$field_name . '_value']['type'] = "bigint"; + $field_schema[$table]['fields'][$field_name . '_value']['unsigned'] = "true"; + } + $storage_schema->set($storage_key, $field_schema); + + // Update field storage configuration. + $config = \Drupal::configFactory() + ->getEditable("field.storage.{$entity_type}.{$field_name}"); + $config->set('settings.size', 'big'); + $config->set('settings.unsigned', TRUE); + $config->save(TRUE); + + // Make sure the new config persists. + FieldStorageConfig::loadByName($entity_type, $field_name)->save(); + + // Reload the data. + foreach ($data as $table => $rows) { + foreach ($rows as $row) { + $database->insert($table) + ->fields((array) $row) + ->execute(); + } + } + + return t('Length of @entity-type.@field-name updated to an unsigned big int', [ + '@entity-type' => $entity_type, + '@field-name' => $field_name, + ]); +}