From 089fab35eaa304bbf77846dda9def62c8c56e858 Mon Sep 17 00:00:00 2001
From: lang14 <lang14@gmail.com>
Date: Thu, 11 Aug 2011 11:32:23 -0400
Subject: [PATCH] Added poll_update_6220 to add an auto_increment field

---
 poll.install |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/poll.install b/poll.install
index 5dd977d..f7a2d13 100644
--- a/poll.install
+++ b/poll.install
@@ -92,6 +92,12 @@ function poll_schema() {
   $schema['poll_votes'] = array(
     'description' => 'Stores per-{users} votes for each {poll}.',
     'fields' => array(
+      'void' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => 'The {poll_vote} id.',
+        ),
       'nid'      => array(
         'type' => 'int',
         'unsigned' => TRUE,
@@ -119,7 +125,7 @@ function poll_schema() {
         'description' => 'The IP address this vote is from unless the voter was logged in.',
         ),
       ),
-    'primary key' => array('nid', 'uid', 'hostname'),
+    'primary key' => array('void', 'nid', 'uid', 'hostname'),
     'indexes' => array(
       'hostname' => array('hostname'),
       'uid'      => array('uid'),
@@ -129,3 +135,23 @@ function poll_schema() {
   return $schema;
 }
 
+function poll_update_6220(&$sandbox) {
+    $ret = array();
+    db_add_field($ret, 'poll_votes', 'void', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The {poll_vote} id.'));
+
+    $result = db_query("ALTER TABLE {poll_votes} DROP PRIMARY KEY, ADD PRIMARY KEY ( `nid` , `uid` , `hostname` , `void` )");
+    if ($result) {
+      $ret[] = array('success' => 1, 'query' => "ALTER TABLE {poll_votes} DROP PRIMARY KEY, ADD PRIMARY KEY ( `nid` , `uid` , `hostname` , `void` )");
+    } else {
+      $ret[] = array('success' => 0, 'query' => db_error());
+    }
+
+    $result = db_query("ALTER TABLE {poll_votes} CHANGE `void` `void` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT");
+    if ($result) {
+      $ret[] = array('success' => 1, 'query' => "ALTER TABLE {poll_votes} CHANGE `void` `void` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT");
+    } else {
+      $ret[] = array('success' => 0, 'query' => db_error());
+    }
+
+    return $ret;
+}
-- 
1.7.1

