aboutsummaryrefslogtreecommitdiff
path: root/muamba.install
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-09-24 19:52:36 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-09-24 19:52:36 -0300
commit4f15de058dc6dadee6e79d16b441202b54161f02 (patch)
treed3c1afe31b73d8736e785e24a868b0f7c148a1de /muamba.install
parent043d624016705e2b54772e5b6b248024e060bbce (diff)
downloadmuamba-4f15de058dc6dadee6e79d16b441202b54161f02.tar.gz
muamba-4f15de058dc6dadee6e79d16b441202b54161f02.tar.bz2
Adding transactional fields to muamba data model
Diffstat (limited to 'muamba.install')
-rw-r--r--muamba.install74
1 files changed, 74 insertions, 0 deletions
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'),
+ )
+ )
+ )
+ );
+}