Description of the need
Add hook_field_schema_alter()
, as described in https://www.drupal.org/node/691932, which has been merged into Drupal 7 core as of 7.99. See https://www.drupal.org/node/3406312
For the reasons we have hook_schema_alter() - mainly site-specific tweaks, we should allow the same for field storage.
It would make it easier to implement a contrib module (like date_repeat
) that would alter core fields (like core date fields).
Proposed solution
Apply this patch: https://www.drupal.org/files/issues/2023-03-16/drupal-field_schema_alter... or similar.
Alternatives that have been considered
hook_schema_alter()
can be used too but it requires checking for each table to see if it's of the right field type and also requires also handling field creation and deletion so it's more work than the proposed new hook.
Example implementation
``` /** * Allow modules to alter the schema for a field. * * @param array $schema * The schema definition as returned by hook_field_schema(). * @param array $field * The field definition. * * @see field_retrieve_schema() */ function hook_field_schema_alter(&$schema, $field) { if ($field['type'] == 'image') { // Alter the length of a field. $schema['columns']['alt']['length'] = 2048; // Add an additional column of data. $schema['columns']['additional_column'] = array( 'description' => "Additional column added to image field table.", 'type' => 'varchar', 'length' => 128, 'not null' => FALSE, ); // Add an additional index. $schema['indexes']['fid_additional_column'] = array('fid', 'additional_column'); } } ````
Recent comments
Argiepiano, you're incredibly helpful; I should have paid closer attention to the error notifications.
D7->B, How do I specify multiple databases in settings.php
I think I've got a handle on Layouts. What is the difference between Cards and Blocks?
Themes: anything like ZEN?
I don't think I said that I liked Zen :-) It's just that I used it on a couple of fairly large sites and was comfortable with it. Learning layouts has got to be easier than learning D10. I...
Themes: anything like ZEN?