Commit 84aa3616 authored by pingers's avatar pingers

#1914326 Resolve missing uid on crm_core_contact table.

parent 0a48dc5b
......@@ -84,6 +84,12 @@ function crm_core_contact_schema() {
'default' => 0,
'description' => 'Timestamp for when contact was last changed',
),
'uid' => array(
'description' => 'The {users}.uid that owns this contact; initially, this is the user that created it.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'created' => array('created'),
......@@ -250,3 +256,29 @@ function crm_core_contact_update_7002() {
'serialize' => TRUE,
));
}
/**
* Add missing uid to contact base table. See http://drupal.org/node/1914326.
*/
function crm_core_contact_update_7003() {
$table = 'crm_core_contact';
db_add_field($table, 'uid', array(
'description' => 'The {users}.uid that owns this contact; initially, this is the user that created it.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
)
);
// Restore missing data from the revisions table.
db_query("UPDATE {crm_core_contact}
INNER JOIN (
SELECT MAX({crm_core_contact_revision}.vid), uid, contact_id
FROM {crm_core_contact_revision}
WHERE {crm_core_contact_revision}.uid > 0
GROUP BY {crm_core_contact_revision}.contact_id
) contact_revisions ON ({crm_core_contact}.contact_id = contact_revisions.contact_id)
SET {crm_core_contact}.uid = contact_revisions.uid");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment