fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [10201] bim: add location_id to bim_item


From: Sigurd Nes
Subject: [Fmsystem-commits] [10201] bim: add location_id to bim_item
Date: Wed, 10 Oct 2012 13:52:35 +0000

Revision: 10201
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10201
Author:   sigurdne
Date:     2012-10-10 13:52:34 +0000 (Wed, 10 Oct 2012)
Log Message:
-----------
bim: add location_id to bim_item

Modified Paths:
--------------
    trunk/bim/setup/setup.inc.php
    trunk/bim/setup/tables_current.inc.php
    trunk/bim/setup/tables_update.inc.php

Modified: trunk/bim/setup/setup.inc.php
===================================================================
--- trunk/bim/setup/setup.inc.php       2012-10-10 13:13:38 UTC (rev 10200)
+++ trunk/bim/setup/setup.inc.php       2012-10-10 13:52:34 UTC (rev 10201)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['bim']['name']                      = 'bim';
-       $setup_info['bim']['version']           = '0.9.17.504';
+       $setup_info['bim']['version']           = '0.9.17.505';
        $setup_info['bim']['app_order']         = 8;
        $setup_info['bim']['enable']            = 1;
        $setup_info['bim']['app_group']         = 'office';

Modified: trunk/bim/setup/tables_current.inc.php
===================================================================
--- trunk/bim/setup/tables_current.inc.php      2012-10-10 13:13:38 UTC (rev 
10200)
+++ trunk/bim/setup/tables_current.inc.php      2012-10-10 13:52:34 UTC (rev 
10201)
@@ -47,8 +47,9 @@
                ),
                'fm_bim_item' => array(
                        'fd' => array(
+                               'location_id' => array('type' => 'int', 
'precision' => 4,'nullable' => False),
+                               'id' => array('type' => 'int', 'precision' => 
4, 'nullable' => False),
                                'type' => array('type' => 'int', 'precision' => 
4,'nullable' => False),
-                               'id' => array('type' => 'int', 'precision' => 
4, 'nullable' => False),
                                'guid' => array('type' => 'varchar', 
'precision' => 50,'nullable' => False),
                                'xml_representation' => array('type' => 
'xml','nullable' => False),
                                'model' => array('type' => 'int', 'precision' 
=> 4,'nullable' => False),
@@ -61,9 +62,10 @@
                                'user_id' => array('type' => 'int','precision' 
=> '4','nullable' => True),
                        ),
                        'pk' => array('type','id'),
-                       'fk' => array('fm_bim_type' => array('type' => 'id')),
-//                     'fk' => array('fm_bim_model' => array('model' => 'id'),
-//                                                     'fm_bim_type' => 
array('type' => 'id')),
+                       'fk' => array(
+                                       'fm_bim_type' => array('type' => 'id'),
+                                       'phpgw_locations' => 
array('location_id' => 'location_id')
+                               ),
                        'ix' => array(),
                        'uc' => array('guid')
                )

Modified: trunk/bim/setup/tables_update.inc.php
===================================================================
--- trunk/bim/setup/tables_update.inc.php       2012-10-10 13:13:38 UTC (rev 
10200)
+++ trunk/bim/setup/tables_update.inc.php       2012-10-10 13:52:34 UTC (rev 
10201)
@@ -82,3 +82,46 @@
                        return $GLOBALS['setup_info']['bim']['currentver'];
                }
        }
+       /**
+       * Update bim version from 0.9.17.504 to 0.9.17.505
+       */
+       $test[] = '0.9.17.504';
+       function bim_upgrade0_9_17_504()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_bim_item','location_id', 
array('type' => 'int', 'precision' => 4,'nullable' => true));
+
+
+               $GLOBALS['phpgw_setup']->oProc->query("SELECT * FROM 
fm_bim_type",__LINE__,__FILE__);
+
+               $values = array();
+               while ($GLOBALS['phpgw_setup']->oProc->next_record())
+               {
+                       $types[] = array
+                       (
+                               'id'                    => 
(int)$GLOBALS['phpgw_setup']->oProc->f('id'),
+                               'location_id'   => 
(int)$GLOBALS['phpgw_setup']->oProc->f('location_id'),
+                               'name'                  => 
$GLOBALS['phpgw_setup']->oProc->f('name',true),
+                               'description'   => 
$GLOBALS['phpgw_setup']->oProc->f('description',true)
+                       );
+               }
+
+               foreach ($types as $entry)
+               {
+                       if(!$location_id = $entry['location_id'])
+                       {
+                               $location_id = 
$GLOBALS['phpgw']->locations->add($entry['name'], $entry['description'], 'bim');
+                       }
+
+                       $GLOBALS['phpgw_setup']->oProc->query("UPDATE 
fm_bim_item SET location_id = {$location_id} WHERE type = 
{$entry['id']}",__LINE__,__FILE__);
+               }
+
+               
$GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_bim_item','location_id', 
array('type' => 'int', 'precision' => 4,'nullable' => false));
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['bim']['currentver'] = 
'0.9.17.505';
+                       return $GLOBALS['setup_info']['bim']['currentver'];
+               }
+       }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]