]> src.bluestatic.org Git - bugdar.git/blob - docs/migrate_custom_fields.php
r1600: Merging r1599 from trunk to fix bug://report/97
[bugdar.git] / docs / migrate_custom_fields.php
1 <?php
2
3 // migrates custom field data from bugvaluefill to bug
4 // SVN $Id$
5
6 chdir('../');
7 require_once('global.php');
8
9 // gets all the fields
10 $fields = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield");
11 while ($field = $db->fetch_array($fields))
12 {
13 // create the database field
14 $db->query("ALTER TABLE " . TABLE_PREFIX . "bug ADD custom$field[fieldid] MEDIUMTEXT NULL");
15
16 // update all the data
17 $data = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill");
18 while ($custom = $db->fetch_array($data))
19 {
20 $db->query("UPDATE " . TABLE_PREFIX . "bug SET custom$field[fieldid] = '" . $db->escape_string($custom["field$field[fieldid]"]) . "' WHERE bugid = $custom[bugid]");
21 }
22 }
23
24 ?>