function system_update_6016 in Drupal 6
Make {node}'s primary key be nid, change nid,vid to a unique key. Add primary keys to block, filters, flood, permission, and term_relation.
Related topics
File
- modules/
system/ system.install, line 1498
Code
function system_update_6016() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {node} ADD CONSTRAINT {node}_nid_vid_key UNIQUE (nid, vid)");
db_add_column($ret, 'blocks', 'bid', 'serial');
$ret[] = update_sql("ALTER TABLE {blocks} ADD PRIMARY KEY (bid)");
db_add_column($ret, 'filters', 'fid', 'serial');
$ret[] = update_sql("ALTER TABLE {filters} ADD PRIMARY KEY (fid)");
db_add_column($ret, 'flood', 'fid', 'serial');
$ret[] = update_sql("ALTER TABLE {flood} ADD PRIMARY KEY (fid)");
db_add_column($ret, 'permission', 'pid', 'serial');
$ret[] = update_sql("ALTER TABLE {permission} ADD PRIMARY KEY (pid)");
db_add_column($ret, 'term_relation', 'trid', 'serial');
$ret[] = update_sql("ALTER TABLE {term_relation} ADD PRIMARY KEY (trid)");
db_add_column($ret, 'term_synonym', 'tsid', 'serial');
$ret[] = update_sql("ALTER TABLE {term_synonym} ADD PRIMARY KEY (tsid)");
break;
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {node} ADD UNIQUE KEY nid_vid (nid, vid)');
$ret[] = update_sql("ALTER TABLE {blocks} ADD bid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {filters} ADD fid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {flood} ADD fid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {permission} ADD pid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {term_relation} ADD trid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {term_synonym} ADD tsid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
break;
}
return $ret;
}