Subversion Repositories computer_asset_manager_v1

Rev

Rev 100 | Rev 102 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
99 rodolico 1
/* this is only for upgrades */
2
create or replace table temp as select * from attrib;
3
/* end start upgrades */
4
 
101 rodolico 5
create or replace table attrib (
99 rodolico 6
  attrib_id       int(10) unsigned NOT NULL auto_increment,
7
  attrib_category_id int unsigned default 1 references attrib_category( attrib_category_id ),
8
  name            varchar(64) not null unique COMMENT 'the visible displayed name',
101 rodolico 9
  added_date      date not null COMMENT 'date record was added',
10
  removed_date    date default NULL COMMENT 'date record was deleted or supserceded',
11
  keyname         varchar(32) comment 'used for sysinfo really needs to be separate table',
99 rodolico 12
  PRIMARY KEY     (attrib_id)
101 rodolico 13
) comment 'attributes that can be applied to a device';
99 rodolico 14
 
101 rodolico 15
create  or replace table attrib_category (
16
   attrib_category_id int unsigned not null auto_increment,
17
   name           varchar(64),
18
   added_date     date not null comment 'When this category was added',
19
   primary key    (attrib_category_id)
20
) comment 'just allows us to categorize attributes';
21
 
22
CREATE  or replace TABLE attrib_device (
99 rodolico 23
  attrib_device_id int unsigned not null auto_increment,
24
  device_id       int(10) unsigned NOT NULL REFERENCES device(device_id),
25
  attrib_id       int(10) unsigned NOT NULL REFERENCES attrib(attrib_id),
26
  value           text COMMENT 'The actual value of this attribute.',
101 rodolico 27
  added_date      date NOT NULL COMMENT 'date record was added',
28
  removed_date    date default NULL,
99 rodolico 29
  PRIMARY KEY     (attrib_device_id)
30
)  COMMENT='links devices and their attributes together';
31
 
32
insert into attrib_category values ( 1,'General',now() );
33
 
34
/* set up the _system table to plug in the module */
35
/* this is required, and officially installs the module */
36
insert into _system ( group_name,key_name,theValue,added_date) values ( 'Modules', 'Attributes', 'modules/attributes/', now() );
37
/* we will provide data to the main screen via a callback routine. In this case, function view is located in callable.php */
100 rodolico 38
insert into _system( group_name,key_name,theValue,added_date ) values ( 'device view', 'Attributes', 'callable.php:attributeView', now() );
99 rodolico 39
 
40
/* This has a menu entry, so add it */
41
/* first, make sure we don't have any danglies */
42
/* create three menu options. First one is the main menu option (ie, no parent_id) */
43
insert into menu( url, caption, parent_id) values ('/modules/attributes' , 'Attributes', null);
44
/* two additional menu options for bulk_load and editing the license_product table */
45
insert into menu( url,caption,parent_id) select '/modules/attributes/bulk_load.html','Bulk Load',menu_id from menu where caption = 'Attributes';
46
insert into menu( url,caption,parent_id) select '/modules/attributes/dmidecode_load.html','Load dmidecode file',menu_id from menu where caption = 'Attributes';
47
insert into menu( url,caption,parent_id) select '/modules/attributes/edit_device_attributes.html','Edit Device',menu_id from menu where caption = 'Attributes';
48
 
49
/* give all administrators the new menu */
50
insert into login_menu
51
   select null,login_id,menu_id
52
   from login,menu
53
   where 
54
      login.removed_date is null
55
      and login.where_clause = '1=1'
56
      and (
57
         menu.caption = 'Attributes'
58
         or menu.parent_id = (select menu_id from menu where caption = 'Attributes')
59
         )
60
;
61
 
62
 
63
/* do this only for upgrades */
64
insert into attrib (attrib_id,name,added_date,removed_date,keyname) select * from temp;
65
insert into attrib_device select device_attrib_id,device_id,attrib_id,value,added_date,removed_date from device_attrib;
66
 
67
drop table temp;
68
drop table device_attrib;
69
/* end of only for upgrades section */