As discussed at length in #866340: Remove support for date and time types, it would be very useful to have a way to dynamically change the column specification passed to db_create_table(), db_add_field() and db_change_field().
That would allow contrib modules (like the date module) to implement new portable types (date, datetime, time by the date module, for example, but we can also think about gis types or xml types).
We already have hook_schema_alter(), but it is only designed to alter the conceptual schema, and is not called (nor arguably supposed to be called) when creating the actual database structures.
Comment | File | Size | Author |
---|---|---|---|
#5 | schema_alter_ideas.patch | 1.03 KB | jpstrikesback |
Comments
Comment #1
rfaySo should this be critical? And a task?
Comment #2
KarenS CreditAttribution: KarenS commentedI don't think this is a feature request. We can do this in D6, without it we have a regression. I don't mean we have a an alter() in D6, I mean we are able to create a table with a field type that is not defined by core without errors.
And I would call it critical because it is a post-freeze regression without this capability.
Comment #3
Damien Tournoud CreditAttribution: Damien Tournoud commentedKarenS, please don't confuse this with #927828: Some schema code incorrectly rely on the generic type instead of the engine-specific type, which is the actual bug that prevents creation of fields without a generic type.
Comment #4
KarenS CreditAttribution: KarenS commentedOK, if that issue will fix the problem.
Comment #5
jpstrikesback CreditAttribution: jpstrikesback commentedHere is a few ideas, probably incomplete but it works for the alter at table creation use-case:
Used like so (thanks for the schema_alter examples in #866340 Damien and in Date KarenS):
Comment #7
bjaspan CreditAttribution: bjaspan commentedI'm only just coming up to speed on this issue now. One thought re: the code in #5: Since we're still using anonymous arrays for Schema API, AFAIK nothing at all prevents you from putting any random properties into a field structure that you want, e.g.
Then in a hook_schema_alter() you can check for $field['mydate_type'] and change $field['type'] appropriately, and fail with an explicit error if the engine type is not supported by the mydate module. The 'type' => 'int' is a lie but will either be fixed up by hook_schema_alter() or irrelevant because the module will not install or throw an error.
Comment #8
jpstrikesback CreditAttribution: jpstrikesback commented@bjaspan How would this work for fields (fields in core fields) at table creation? For example...a drupal-field that uses datetime type db-field?
Comment #9
KarenS CreditAttribution: KarenS commented@bjaspan, I tried that idea initially and ran into trouble, as I described in http://drupal.org/node/866340#comment-3265428. I ended up doing this by using schema_alter() instead, which is also currently broken.
Comment #10
Panchomoved this as a feature request to the D8 queue
Comment #11
jhedstromWhile this is technically a feature request, since it was a regression from D6, I wonder if this is still possible to get into 8.0?
Comment #12
jhedstromFeature request => 8.1.x.