Subversion Repositories computer_asset_manager_v2

Rev

Rev 38 | Blame | Last modification | View Log | Download | RSS feed

insert into camp2.client( client_id,name,notes,internal_notes,added,removed )
   select client_id,name,notes,internal_notes,added_date,removed_date from camp.client;
update camp2.client set notes = null where length( notes ) = 0;
update camp2.client set internal_notes = null where length( internal_notes ) = 0;

/* load site */
insert into camp2.site( site_id,name,notes,added,removed ) 
   select site_id,name,notes,added_date,removed_date 
   from camp.site;

/* load device types, convert show_as_system to flags */
insert into camp2.device_type( device_type_id,name,flags,added,removed) 
   select device_type_id,name,if(show_as_system='Y',1,0),added_date,removed_date 
   from camp.device_type;

/* load only actual devices into device */
insert into camp2.device( device_id,device_type_id,name,notes,added,removed ) 
   select device_id,device_type_id,name,notes,added_date,removed_date 
   from camp.device 
   where camp.device.device_type_id in (
      select device_type_id 
      from camp.device_type 
      where camp.device_type.show_as_system = 'Y'
      );

/* now, populate joining tables site_device and client_device and client_site */
insert into camp2.site_device (site_id,device_id,added,removed)
   select site_id,device_id,added_date,removed_date 
   from camp.device
   where device_type_id in ( select device_type_id from camp.device_type where show_as_system = 'Y');

insert into camp2.client_device (client_id,device_id,added,removed) 
   select client_id,device_id,device.added_date,device.removed_date 
   from camp.device join camp.site using (site_id)
   where device_type_id in ( select device_type_id from camp.device_type where show_as_system = 'Y');
   
insert into camp2.client_site ( client_id,site_id,added,removed ) 
   select client_id,site_id,added_date,removed_date 
   from camp.site;



/* and fill out device_relationship */

insert into camp2.device_device( device_id, parent_id, added, removed )
   select camp2.device.device_id, camp.device.part_of, camp2.device.added,camp2.device.removed
   from camp2.device join camp.device using (device_id)
   where camp.device.part_of is not null;