|
|
@ -16,33 +16,31 @@ function islandora_core_feature_update_8001() { |
|
|
|
$field_name = 'field_file_size'; |
|
|
|
$field_name = 'field_file_size'; |
|
|
|
|
|
|
|
|
|
|
|
$database = \Drupal::database(); |
|
|
|
$database = \Drupal::database(); |
|
|
|
$data = []; |
|
|
|
$tables = [ |
|
|
|
$storage_key = $entity_type . '.field_schema_data.' . $field_name; |
|
|
|
|
|
|
|
$storage_schema = \Drupal::keyValue('entity.storage_schema.sql'); |
|
|
|
|
|
|
|
$field_schema = $storage_schema->get($storage_key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ([ |
|
|
|
|
|
|
|
"{$entity_type}__{$field_name}", |
|
|
|
"{$entity_type}__{$field_name}", |
|
|
|
"{$entity_type}_revision__{$field_name}", |
|
|
|
"{$entity_type}_revision__{$field_name}", |
|
|
|
] as $table) { |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($tables as $table) { |
|
|
|
|
|
|
|
|
|
|
|
// Squirrel away the data. |
|
|
|
// Squirrel away the data. |
|
|
|
$data[$table] = $database->select($table, 'n') |
|
|
|
$table_file_path = "public://islandora_core_feature_update_8001_{$table}.json"; |
|
|
|
->fields('n') |
|
|
|
if (!file_exists($table_file_path)) { |
|
|
|
->execute() |
|
|
|
$table_data = $database->select($table, 'n')->fields('n')->execute()->fetchAll(); |
|
|
|
->fetchAll(); |
|
|
|
\Drupal::service('file_system')->saveData(json_encode($table_data), $table_file_path); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Clean it out for resizing. |
|
|
|
// Clean it out for resizing. |
|
|
|
$database->truncate($table)->execute(); |
|
|
|
$database->truncate($table)->execute(); |
|
|
|
$database->schema()->dropPrimaryKey($table); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Resize the main field data table. |
|
|
|
$database->schema()->changeField($table, $field_name . '_value', $field_name . '_value', [ |
|
|
|
$database->query("ALTER TABLE $table MODIFY {$field_name}_value BIGINT(11) unsigned NOT NULL"); |
|
|
|
'type' => 'int', |
|
|
|
|
|
|
|
'size' => 'big', |
|
|
|
|
|
|
|
'unsigned' => TRUE, |
|
|
|
|
|
|
|
'not null' => TRUE, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
// 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. |
|
|
|
// Update field storage configuration. |
|
|
|
$config = \Drupal::configFactory() |
|
|
|
$config = \Drupal::configFactory() |
|
|
@ -55,12 +53,18 @@ function islandora_core_feature_update_8001() { |
|
|
|
FieldStorageConfig::loadByName($entity_type, $field_name)->save(); |
|
|
|
FieldStorageConfig::loadByName($entity_type, $field_name)->save(); |
|
|
|
|
|
|
|
|
|
|
|
// Reload the data. |
|
|
|
// Reload the data. |
|
|
|
foreach ($data as $table => $rows) { |
|
|
|
foreach ($tables as $table) { |
|
|
|
foreach ($rows as $row) { |
|
|
|
$table_file_path = "public://islandora_core_feature_update_8001_{$table}.json"; |
|
|
|
|
|
|
|
if (file_exists($table_file_path)) { |
|
|
|
|
|
|
|
foreach (json_decode(file_get_contents($table_file_path), TRUE) as $row) { |
|
|
|
$database->insert($table) |
|
|
|
$database->insert($table) |
|
|
|
->fields((array) $row) |
|
|
|
->fields((array) $row) |
|
|
|
->execute(); |
|
|
|
->execute(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Clean up. |
|
|
|
|
|
|
|
\Drupal::service('file_system')->delete($table_file_path); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return t('Length of @entity-type.@field-name updated to an unsigned big int', [ |
|
|
|
return t('Length of @entity-type.@field-name updated to an unsigned big int', [ |
|
|
|