function serial_update_7130 in Serial Field 7
Upgrade path.
Switches from nids to uniqids.
File
- ./
serial.install, line 52 - Install, update and uninstall functions for the Serial module.
Code
function serial_update_7130() {
module_load_include('inc', 'serial');
$table_schema = _serial_get_table_schema();
// Update the schema of old assistant tables.
foreach (_serial_get_all_fields() as $field) {
// Empty the table.
$table = _serial_get_table_name($field->entity_type, $field->bundle, $field->field_name);
db_delete($table)
->execute();
// Drop nid field and key.
db_drop_field($table, 'nid');
db_drop_unique_key($table, 'nid');
// Add uniqid field and key.
db_add_field($table, 'uniqid', $table_schema['fields']['uniqid']);
db_add_unique_key($table, 'uniqid', array(
'uniqid',
));
}
}