Loading src/FieldTypeUpdateUtil.php +20 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,26 @@ class FieldTypeUpdateUtil { $database = \Drupal::database(); $existing_data = []; foreach ($tables as $table) { // Create any new fields from the field schema // if they don't exist in the database table. $field_schema = $field_storage_definition->getSchema(); $columns = $table_mapping->getColumnNames($field_name); if (!empty($field_schema['columns'])) { foreach ($field_schema['columns'] as $column_name => $column_data) { $table_exists = $schema->tableExists($table); if ($table_exists) { $field_exists = $schema->fieldExists($table, $columns[$column_name]); if ($field_exists === FALSE) { $schema->addField($table, $columns[$column_name], $column_data); } } } // Caches have to be cleared first to ensure // new fields are detected in the code. drupal_flush_all_caches(); } // Get the old data. $existing_data[$table] = $database->select($table) ->fields($table) Loading Loading
src/FieldTypeUpdateUtil.php +20 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,26 @@ class FieldTypeUpdateUtil { $database = \Drupal::database(); $existing_data = []; foreach ($tables as $table) { // Create any new fields from the field schema // if they don't exist in the database table. $field_schema = $field_storage_definition->getSchema(); $columns = $table_mapping->getColumnNames($field_name); if (!empty($field_schema['columns'])) { foreach ($field_schema['columns'] as $column_name => $column_data) { $table_exists = $schema->tableExists($table); if ($table_exists) { $field_exists = $schema->fieldExists($table, $columns[$column_name]); if ($field_exists === FALSE) { $schema->addField($table, $columns[$column_name], $column_data); } } } // Caches have to be cleared first to ensure // new fields are detected in the code. drupal_flush_all_caches(); } // Get the old data. $existing_data[$table] = $database->select($table) ->fields($table) Loading