1

I need to add a information to a content types within my module. Generally, is it good practise to update node_type schema or is it better to create my own and join it to the node_type via primary key?

Thanks.

1

You should make use of the hook_schema_alter to update entity schema of existing schema's.

function YOURMODULE_schema_alter(&$schema) {
  // Add field to existing schema.
  $schema['users']['fields']['timezone_id'] = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'description' => 'Per-user timezone configuration.',
  );
}
| improve this answer | |
  • Thanks for your answer, Mike, however, my question wasn't which hook should I use, but what is the best practise - update existing schema or create a new one. – petiar Mar 2 '15 at 17:08
  • 1
    It depends on the complexity of your information you need to add on your content type. If it is 1 piece of content, you generally alter the existing schema. On the other hand, if you have a lot of extra information to store, you create your own schema. It is also your job to load / save / ... the extra data which requires a lot more development if you go for option 2. – Mike Vranckx Mar 3 '15 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.