hook_update and hook_schema
function hook_update_7100() {
$spec = array(
'type' => 'int',
'description' => "test ",
'default' => 0,
);
db_add_field( 'stud_payment', 'status', $spec);
}
/** New sample.
* Add column1 and column2 fields to table {my_module_node_properties}
*/
function my_module_update_7004() {
$table = 'my_module_node_properties';
$schema = drupal_get_schema_unprocessed('my_module', $table);
foreach (array('new_column1', 'new_column2') as $field) {
db_add_field($table, $field, $schema['fields'][$field]);
}
}
function hook_schema() {
$schema = array();
$schema['orders'] = array(
'description' => 'Stores order information.',
'fields' => array(
'order_id' => array(
'description' => 'Primary key: the order ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'order_status' => array(
'description' => 'The {order_statuses}.order_status_id indicating the order status.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'order_total' => array(
'description' => 'The total amount to be paid for the order.',
'type' => 'numeric',
'precision' => 16,
'scale' => 5,
'not null' => TRUE,
'default' => 0.0,
),
'promo_code' => array(
'description' => 'Promo Code',
'type' => 'varchar',
'length' => 20,
'not null' => FALSE,
'default' => '',
),
'primary_email' => array(
'description' => 'The email address of the customer.',
'type' => 'varchar',
'length' => 96,
'not null' => TRUE,
'default' => '',
),
'data' => array(
'description' => 'A serialized array of extra data.',
'type' => 'text',
'serialize' => TRUE,
),
'created' => array(
'description' => 'The Unix timestamp indicating when the order was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'notification_text' => array(
'type' => 'text',
'description' => 'Message Text',
'size' => 'big',
'not null' => TRUE,
),
),
'indexes' => array(
'primary_email' => array('primary_email'),
),
'primary key' => array('order_id'),
'foreign keys' => array(
'order_statuses' => array(
'table' => 'order_statuses',
'columns' => array('order_status' => 'order_status_id'),
),
),
);
return $schema;
}