Switch the 'modify' code of admin/field.php to use templates
[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 foreach ($fields as $field)
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 foreach ($data as $custom)
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 ?>