| Line 1... | Line 1... | 
          
            | 1 | /* this is only for upgrades */
 | 1 | /* this is only for upgrades */
 | 
          
            | 2 | create or replace table temp as select * from attrib;
 | 2 | create or replace table temp as select * from attrib;
 | 
          
            | 3 | /* end start upgrades */
 | 3 | /* end start upgrades */
 | 
          
            | 4 |  
 | 4 |  
 | 
          
            | 5 | /* this contains the attributes we can use information itself */
 | - |   | 
          
            | 6 | CREATE or replace TABLE attrib (
 | 5 | create or replace table attrib (
 | 
          
            | 7 |   attrib_id       int(10) unsigned NOT NULL auto_increment,
 | 6 |   attrib_id       int(10) unsigned NOT NULL auto_increment,
 | 
          
            | 8 |   attrib_category_id int unsigned default 1 references attrib_category( attrib_category_id ),
 | 7 |   attrib_category_id int unsigned default 1 references attrib_category( attrib_category_id ),
 | 
          
            | 9 |   name            varchar(64) not null unique COMMENT 'the visible displayed name',
 | 8 |   name            varchar(64) not null unique COMMENT 'the visible displayed name',
 | 
          
            | 10 |   added_date      datetime not null COMMENT 'date record was added',
 | 9 |   added_date      date not null COMMENT 'date record was added',
 | 
          
            | 11 |   removed_date    datetime default NULL COMMENT 'date record was deleted/supserceded',
 | 10 |   removed_date    date default NULL COMMENT 'date record was deleted or supserceded',
 | 
          
            | 12 |   keyname         varchar(32) comment 'used for sysinfo, really needs to be separate table',
 | 11 |   keyname         varchar(32) comment 'used for sysinfo really needs to be separate table',
 | 
          
            | 13 |   PRIMARY KEY     (attrib_id)
 | 12 |   PRIMARY KEY     (attrib_id)
 | 
          
            | 14 | )   COMMENT='These are attributes that can be applied to a device';
 | 13 | ) comment 'attributes that can be applied to a device';
 | 
          
            | 15 |  
 | 14 |  
 | 
          
            | - |   | 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 |  
 | 
          
            | 16 | CREATE or replace TABLE attrib_device (
 | 22 | CREATE  or replace TABLE attrib_device (
 | 
          
            | 17 |   attrib_device_id int unsigned not null auto_increment,
 | 23 |   attrib_device_id int unsigned not null auto_increment,
 | 
          
            | 18 |   device_id       int(10) unsigned NOT NULL REFERENCES device(device_id),
 | 24 |   device_id       int(10) unsigned NOT NULL REFERENCES device(device_id),
 | 
          
            | 19 |   attrib_id       int(10) unsigned NOT NULL REFERENCES attrib(attrib_id),
 | 25 |   attrib_id       int(10) unsigned NOT NULL REFERENCES attrib(attrib_id),
 | 
          
            | 20 |   value           text COMMENT 'The actual value of this attribute.',
 | 26 |   value           text COMMENT 'The actual value of this attribute.',
 | 
          
            | 21 |   added_date      datetime NOT NULL COMMENT 'date record was added',
 | 27 |   added_date      date NOT NULL COMMENT 'date record was added',
 | 
          
            | 22 |   removed_date    datetime default NULL,
 | 28 |   removed_date    date default NULL,
 | 
          
            | 23 |   PRIMARY KEY     (attrib_device_id)
 | 29 |   PRIMARY KEY     (attrib_device_id)
 | 
          
            | 24 | )  COMMENT='links devices and their attributes together';
 | 30 | )  COMMENT='links devices and their attributes together';
 | 
          
            | 25 |  
 | 31 |  
 | 
          
            | 26 | create or replace table attrib_category (
 | - |   | 
          
            | 27 |    attrib_category_id int unsigned not null auto_increment,
 | - |   | 
          
            | 28 |    name           varchar(64),
 | - |   | 
          
            | 29 |    added_date     datetime not null comment 'When this category was added',
 | - |   | 
          
            | 30 |    primary key    (attrib_category_id)
 | - |   | 
          
            | 31 | ) comment 'just allows us to categorize attributes';
 | - |   | 
          
            | 32 |  
 | - |   | 
          
            | 33 | insert into attrib_category values ( 1,'General',now() );
 | 32 | insert into attrib_category values ( 1,'General',now() );
 | 
          
            | 34 |  
 | 33 |  
 | 
          
            | 35 | /* set up the _system table to plug in the module */
 | 34 | /* set up the _system table to plug in the module */
 | 
          
            | 36 | /* this is required, and officially installs the module */
 | 35 | /* this is required, and officially installs the module */
 | 
          
            | 37 | insert into _system ( group_name,key_name,theValue,added_date) values ( 'Modules', 'Attributes', 'modules/attributes/', now() );
 | 36 | insert into _system ( group_name,key_name,theValue,added_date) values ( 'Modules', 'Attributes', 'modules/attributes/', now() );
 |