From 4f15de058dc6dadee6e79d16b441202b54161f02 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 24 Sep 2011 19:52:36 -0300 Subject: Adding transactional fields to muamba data model --- muamba.install | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'muamba.install') diff --git a/muamba.install b/muamba.install index ab0bcef..e6b3ead 100644 --- a/muamba.install +++ b/muamba.install @@ -21,6 +21,12 @@ function muamba_schema() { $schema['muamba'] = array( 'description' => 'The base table for muamba assets.', 'fields' => array( + 'mid' => array( + 'description' => t('The primary identifier for a muamba transaction.'), + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), 'nid' => array( 'description' => t('The {node}.nid of the borrowed item.'), 'type' => 'int', @@ -35,6 +41,20 @@ function muamba_schema() { 'not null' => TRUE, 'default' => 0, ), + 'thread_id' => array( + 'description' => t('The {thread}.thread_id for the transaction.'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'status' => array( + 'description' => t('Transaction status.'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), ), 'foreign keys' => array( 'node' => array( @@ -45,8 +65,62 @@ function muamba_schema() { 'table' => 'users', 'columns' => array('uid' => 'uid'), ), + 'thread' => array( + 'table' => 'pm_index', + 'columns' => array('thread_id' => 'thread_id'), + ), ), + 'primary key' => array('mid'), ); return $schema; } + +/** + * Adds transactional fields to muamba data model. + */ +function muamba_update_7000(&$sandbox) { + // Make sure to not run this update twice. + if (db_field_exists('muamba', 'mid')) { + return; + } + + db_add_field('muamba', 'mid', + array( + 'description' => t('The primary identifier for a muamba transaction.'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + ) + ); + + db_add_primary_key('muamba', array('mid')); + + db_add_field('muamba', 'status', + array( + 'description' => t('Transaction status.'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ) + ); + + db_add_field('muamba', 'thread_id', + array( + 'description' => t('The {thread}.thread_id for the transaction.'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + array( + 'foreign keys' => array( + 'thread' => array( + 'table' => 'pm_index', + 'columns' => array('thread_id' => 'thread_id'), + ) + ) + ) + ); +} -- cgit v1.2.3