more module updates

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 18:02:17 +02:00
parent 37fbabab56
commit 7c85261e56
100 changed files with 6518 additions and 913 deletions

View File

@@ -6,7 +6,7 @@
*/
/**
* Implementation of hook_uninstall().
* Implements hook_uninstall().
*/
function serial_uninstall() {
/*
@@ -37,7 +37,7 @@ function serial_field_schema($field) {
}
/**
* Implementation of hook_schema().
* Implements hook_schema().
*/
function serial_schema() {
// Get the standard schema:
@@ -46,10 +46,7 @@ function serial_schema() {
// Build the schema by iteration over all the serial field instances:
$schema = array();
$query = "SELECT i.bundle AS bundle, f.field_name AS field_name ".
"FROM {field_config} f, {field_config_instance} i ".
"WHERE f.field_name = i.field_name AND f.type = 'serial' AND i.deleted = 0";
$result = db_query($query);
$result = _serial_get_all_fields();
foreach ($result as $field) {
$table = _serial_get_table_name($field->bundle, $field->field_name);
$schema[$table] = $table_schema;
@@ -59,3 +56,31 @@ function serial_schema() {
return $schema;
}
/**
* Upgrade path.
*
* Switches from nids to uniqid.
*/
function serial_update_7130() {
// Get the new field schema.
module_load_include('inc', 'serial');
$table_schema = _serial_get_table_schema();
$uniqid_schema = $table_schema['fields']['uniqid'];
// Update the schema of old assistant tables.
$result = _serial_get_all_fields();
foreach ($result as $field) {
// Empty the table.
$table = _serial_get_table_name($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', $uniqid_schema);
db_add_unique_key($table, 'uniqid', array('uniqid'));
}
}