0

I'm writing a module which utilises a .install file to create and configure things - specifically I'm creating a custom line item based on the commerce_example module. Turns out it's quite a bit of code and will take a bit of time to get right.

This is all good, but how can I go about testing this as I'm going? I'll inevitably want to add fields to the install function later on, but to do this I'll need to disable (and uninstall?) the module, deleting the existing line-items, and re-enable every time I need to test if it's working which seems so slow. Is there a better way of working when doing this?

1 Answer 1

0

Yes You can write in your hook_update_N() like this in your mymodule.install file:

function mymodule_update_7001() { db_add_field('table_name', 'field_name', array( 'description' => 'The total amount to be paid for the order.', 'type' => 'numeric', 'precision' => 16, 'scale' => 5, 'not null' => TRUE, 'default' => 0.0, )); } 

After writing this you can simply run your update.php file

1
  • I'm aware of this, but this means I will have a load of update functions as I add fields. I suppose this is the only way. Commented Mar 10, 2017 at 2:29

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.