Closed (fixed)
Project:
Role Watchdog
Version:
6.x-1.2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Aug 2011 at 08:20 UTC
Updated:
25 Sep 2012 at 17:21 UTC
We wanted to views enable the role_watchdog table i.e. allow views to use the role watchdog table as a base table.
To do that, the role watchdog table needs a primary key which it currently does not have as of 6.x-1.2
We have created the following patch which does two things
a) Change the schema and create a primary key 'rwid'
b) Create a hook_update_N
diff --git a/htdocs/sites/all/modules/role_watchdog/role_watchdog.info b/htdocs/sites/all/modules/role_watchdog/role_watchdog.info
index f3b26db..23332ee 100644
--- a/htdocs/sites/all/modules/role_watchdog/role_watchdog.info
+++ b/htdocs/sites/all/modules/role_watchdog/role_watchdog.info
@@ -3,7 +3,7 @@ description = Logs changes to user roles.
core = 6.x
; Information added by drupal.org packaging script on 2011-04-28
-version = "6.x-1.2"
+version = "6.x-1.21" ; custom version
core = "6.x"
project = "role_watchdog"
datestamp = "1304030816"
diff --git a/htdocs/sites/all/modules/role_watchdog/role_watchdog.install b/htdocs/sites/all/modules/role_watchdog/role_watchdog.install
index 98d3bae..1a7e83a 100644
--- a/htdocs/sites/all/modules/role_watchdog/role_watchdog.install
+++ b/htdocs/sites/all/modules/role_watchdog/role_watchdog.install
@@ -12,6 +12,12 @@ function role_watchdog_schema() {
$schema['role_watchdog'] = array(
'description' => t('This table is log of all role changes.'),
'fields' => array(
+ 'rwid' => array(
+ 'description' => t('The unique id of role change'),
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ ),
'aid' => array(
'description' => t('The uid of account.'),
'type' => 'int',
@@ -46,6 +52,7 @@ function role_watchdog_schema() {
'indexes' => array(
'aid' => array('aid'),
),
+ 'primary key' => array('rwid')
);
return $schema;
@@ -82,3 +89,12 @@ function role_watchdog_update_6120() {
variable_del('role_watchdog_history');
return $ret;
}
+
+// Custom update
+// We need to create a primary key on role_watchdog so that it can be views enabled
+function role_watchdog_update_6121() {
+ $ret = array();
+ $ret[] = update_sql("ALTER TABLE {role_watchdog} ADD `rwid` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
+ return $ret;
+}
+
Our request is that this patch be included in future versions of role watchdog if it makes sense to you. If not creating a primary key was a deliberate policy please tell us too.
Comments
Comment #1
greg.1.anderson commentedFixed in the 2.0-beta1 release.