Subversion Repositories computer_asset_manager_v2

Rev

Rev 47 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 47 Rev 48
Line 47... Line 47...
47
  uuid and serial number are stored A) in the table and B) in the attrib_device table.
47
  uuid and serial number are stored A) in the table and B) in the attrib_device table.
48
  We are doing a kludge. If the value is 36 characters long, we assume it is a UUID. If 
48
  We are doing a kludge. If the value is 36 characters long, we assume it is a UUID. If 
49
  it is not, we assume it is a serial number
49
  it is not, we assume it is a serial number
50
*/
50
*/
51
 
51
 
-
 
52
alter table temp add device_uuid varchar(36);
-
 
53
 
52
update temp a join camp.attrib_device b on (a.old_device_id = b.device_id and b.attrib_id = 23 )
54
update temp a join camp.attrib_device b on (a.old_device_id = b.device_id and b.attrib_id = 23 )
53
  set
55
  set
54
     a.device_uuid = b.value
56
     a.device_uuid = b.value
55
   where a.device_uuid is null;
57
   where a.device_uuid is null;
56
  
58
  
Line 63... Line 65...
63
update temp a join camp.attrib_device b on (a.old_device_id = b.device_id and b.attrib_id = 3 )
65
update temp a join camp.attrib_device b on (a.old_device_id = b.device_id and b.attrib_id = 3 )
64
  set
66
  set
65
     a.device_uuid = b.value
67
     a.device_uuid = b.value
66
   where a.device_uuid is null
68
   where a.device_uuid is null
67
      and length( b.value ) = 36;
69
      and length( b.value ) = 36;
-
 
70
      
-
 
71
update temp set device_uuid = device_serial where length( device_serial ) = 36 and device_uuid is null;
-
 
72
update temp set device_serial = null where lower( device_serial ) = lower( device_uuid);
68
 
73
 
69
update temp set device_uuid = trim(device_uuid);
74
update temp set device_uuid = trim(device_uuid);
70
update temp set device_serial = trim(device_serial);
75
update temp set device_serial = trim(device_serial);
71
 
76
 
72
update temp set device_uuid = null where length( device_uuid ) = 0;
77
update temp set device_uuid = null where length( device_uuid ) = 0;
Line 149... Line 154...
149
   show_as_system = 'Y';
154
   show_as_system = 'Y';
150
 
155
 
151
/* Now, we're ready to get some devices */
156
/* Now, we're ready to get some devices */
152
truncate table device;
157
truncate table device;
153
insert into device( uuid,serial,name,created,removed)
158
insert into device( uuid,serial,name,created,removed)
154
   select 
159
   select distinct
155
      device_uuid,
160
      device_uuid,
156
      device_serial,
161
      left(device_serial,32),
157
      device_name,
162
      device_name,
158
      device_added,
163
      device_added,
159
      device_removed
164
      device_removed
160
   from
165
   from
161
      temp
166
      temp
Line 260... Line 265...
260
         ) oldTable
265
         ) oldTable
261
      join device on ( device.name = oldTable.device_name )
266
      join device on ( device.name = oldTable.device_name )
262
      join device parent_device on ( parent_device.name = oldTable.parent );
267
      join device parent_device on ( parent_device.name = oldTable.parent );
263
      
268
      
264
 
269
 
-
 
270
-- get rid of the temp table
-
 
271
drop table if exists temp;