function profile2_update_7105 in Profile 2 7.2
Add revisioning support.
File
- ./
profile2.install, line 379 - Install, update and uninstall functions for the profile module.
Code
function profile2_update_7105() {
db_add_field('profile', 'vid', _profile2_vid_field());
$profile_revision = _profile2_revision_table();
db_create_table('profile_revision', $profile_revision);
// Add version id data to the profile.
db_query('UPDATE {profile} SET vid = pid');
// Add current revision data to the revision table.
db_query("INSERT INTO {profile_revision} (pid, vid, authorid, label, log, timestamp)\n SELECT pid, vid, uid, label, '', UNIX_TIMESTAMP()\n FROM {profile} WHERE uid IS NOT NULL");
db_add_unique_key('profile', 'vid', array(
'vid',
));
// Set the revisions flag for existing profiles.
foreach (profile2_get_types() as $profile_type) {
$profile_type->data['revisions'] = 0;
$profile_type
->save();
}
}