'serial', 'unsigned' => TRUE, 'not null' => TRUE); $links_lid_field_temp = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE); $links_primary_key = array('lid'); $links_unique_keys = array( 'url_ix' => array('url_md5'), 'title_ix' => array('link_title','lid'), 'stale_ix' => array('last_click_time','lid'), ); foreach ($links_unique_keys as $name=>$spec) { db_drop_unique_key($ret, 'links', $name); } // Can't drop the primary key unless we first make this field NOT auto-increment. db_change_field($ret, 'links', 'lid', 'lid', $links_lid_field_temp); db_drop_primary_key($ret, 'links'); db_change_field($ret, 'links', 'lid', 'lid', $links_lid_field, array('primary key'=>$links_primary_key)); foreach ($links_unique_keys as $name=>$fields) { db_add_unique_key($ret, 'links', $name, $fields); } return $ret; } /** * Install the initial schema. */ function links_install() { drupal_install_schema('links'); } /** * Uninstall the module */ function links_uninstall() { drupal_uninstall_schema('links'); } function links_schema() { $schema['links'] = array( 'fields' => array( 'lid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'url_md5' => array('type' => 'char', 'length' => 32, 'not null' => TRUE), 'url' => array('type' => 'text', 'not null' => TRUE), 'link_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE), 'last_click_time' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), ), 'primary key' => array('lid'), 'unique keys' => array( 'url_ix' => array('url_md5'), 'title_ix' => array('link_title','lid'), 'stale_ix' => array('last_click_time','lid'), ), ); $schema['links_node'] = array( 'fields' => array( 'lid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'link_title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE), 'weight' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'size'=>'tiny'), 'clicks' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'module' => array('type' => 'varchar', 'length' => 60, 'not null' => TRUE), ), 'primary key' => array('lid', 'nid', 'module'), 'unique_keys' => array( 'node_link_ix1' => array('nid','module','link_title','lid'), 'node_link_ix2' => array('link_title','nid','module','lid'), 'node_link_ix3' => array('nid','module','lid','weight'), ), ); $schema['links_monitor'] = array( 'fields' => array( 'lid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'check_interval' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'last_check' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'fail_count' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'alternate_monitor_url' => array('type' => 'text', 'not null' => FALSE), 'redirect_propose_url' => array('type' => 'text', 'not null' => FALSE), 'redirect_saved_url' => array('type' => 'text', 'not null' => FALSE), 'change_threshold' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'change_flag' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'size'=>'tiny'), 'change_last_data' => array('type' => 'text', 'not null' => FALSE), ), 'primary key' => array('lid'), 'unique keys' => array( 'check_ix' => array('last_check','check_interval','lid'), 'change_ix' => array('change_flag','last_check','lid'), 'rotted_ix' => array('fail_count','last_check','lid'), ), ); return $schema; }