By Rajan M on
Hello friends,
I want to create a table using drupal_install_schema, I have define all fields within schema but now I am not getting how to add enum type fields.
I can create this table by directly using query in hook_install( ) but i would like to do this in drupal way.
Thanks in advance.
Comments
Rajon, Have a look at the
Rajon,
Have a look at the Schema module. This module provides the functionality to export the Drupal "schema" of any database table. You can use this module to export the schema of a table which contains an ENUM field type and see how it's done.
--
I have just done some quick searching and it appears that the ENUM field type is lacking from the schema API. There's a suggested workaround here, although it's not really a solution to the problem...
---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com
Thanks Yuriy, I will try this.
I will try this and let you know here.
schema doesn't help :-(
I am trying the same. I have defined ENUMs in the table. And i had used the 'Inspect' tab in the schema module to copy the code to be pasted in hook_schema.
But it seems the module installation returns a error that the SQL syntax is incorrect.
Upon closely observing the code from the 'Inspect' tab, i see that though it does say 'type' => 'enum', it does not list the options of the enum.. a sample pasted below.. where the options for t_cooliris_float were (manually) defined to be Left, Right, Center and None in the database
This post in the schema issue queue says that schema module cannot handle ENUMs.
Can someone think of an alternative way of defining ENUMs in drupal?
Alternatively, does drupal's hook_install() itself support enums at all?
edit: a closer look at the schema issue queue post... the limitation seems to be with the drupal schema api :-(
Query is last option for me.
I also tried using schema module, but no success :-(
So i put query in my hook_install and hook_uninstall.