diff --git a/database/database.mysql b/database/database.mysql index 92df2c686c3ef478ecbc454472c9eace9125f9e0..f08db4f6f854f9bcff7bf2e528746106e69a2838 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -546,8 +546,8 @@ CREATE TABLE poll ( CREATE TABLE poll_votes ( nid int(10) unsigned NOT NULL, - uid int(10) unsigned NOT NULL, - hostname varchar(128) NOT NULL, + uid int(10) unsigned NOT NULL default 0, + hostname varchar(128) NOT NULL default '', INDEX (nid), INDEX (uid), INDEX (hostname) diff --git a/database/database.pgsql b/database/database.pgsql index 7883dd06c57405bac7ac7be0fe3f391eeb2cfbbc..782ca52ceffd981cade952c46152429b52ee3fd3 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -540,11 +540,11 @@ CREATE TABLE poll ( -- CREATE TABLE poll_votes ( - nid int(10) NOT NULL, - uid int(10) NOT NULL, - hostname varchar(128) NOT NULL + nid int NOT NULL, + uid int NOT NULL default 0, + hostname varchar(128) NOT NULL default '' ); -CREATE INDEX poll_voter_nid_idx ON poll_votes (nid); +CREATE INDEX poll_votes_nid_idx ON poll_votes (nid); CREATE INDEX poll_votes_uid_idx ON poll_votes (uid); CREATE INDEX poll_votes_hostname_idx ON poll_votes (hostname); diff --git a/database/updates.inc b/database/updates.inc index 26f627342b75a4fd3c21c8519f9210d5c673c436..22412f5d65327f364e8257cd6872164ab4be68df 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -1293,22 +1293,22 @@ function system_update_164() { switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': - $ret[] = update_sql('CREATE TABLE {poll_votes} ( + $ret[] = update_sql("CREATE TABLE {poll_votes} ( nid int(10) unsigned NOT NULL, - uid int(10) unsigned NOT NULL, - hostname varchar(128) NOT NULL, + uid int(10) unsigned NOT NULL default 0, + hostname varchar(128) NOT NULL default '', INDEX (nid), INDEX (uid), INDEX (hostname) - )'); + )"); break; case 'pgsql': - $ret[] = update_sql('CREATE TABLE {poll_votes} ( - nid int(10) NOT NULL, - uid int(10) NOT NULL, - hostname varchar(128) NOT NULL - )'); + $ret[] = update_sql("CREATE TABLE {poll_votes} ( + nid int NOT NULL, + uid int NOT NULL default 0, + hostname varchar(128) NOT NULL default '' + )"); $ret[] = update_sql('CREATE INDEX {poll_votes}_nid_idx ON {poll_votes} (nid)'); $ret[] = update_sql('CREATE INDEX {poll_votes}_uid_idx ON {poll_votes} (uid)'); $ret[] = update_sql('CREATE INDEX {poll_votes}_hostname_idx ON {poll_votes} (hostname)'); @@ -1329,16 +1329,7 @@ function system_update_164() { } } - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql('ALTER TABLE {poll} DROP polled'); - break; - - case 'pgsql': - $ret[] = update_sql('ALTER TABLE {poll} RENAME polled TO polled_old'); - break; - } + $ret[] = update_sql('ALTER TABLE {poll} DROP polled'); return $ret; } diff --git a/modules/poll.module b/modules/poll.module index d3385000b9f70657b020616affafe12aa7602fd1..8ea1cd3e587a86356fdbd6761e580b8024c0e01e 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -87,6 +87,7 @@ function poll_cron() { function poll_delete($node) { db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid); db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid); + db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid); } /** @@ -482,6 +483,7 @@ function poll_update($node) { db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid); db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid); foreach ($node->choice as $choice) { $chvotes = (int)$choice['chvotes']; $chtext = $choice['chtext']; diff --git a/modules/poll/poll.module b/modules/poll/poll.module index d3385000b9f70657b020616affafe12aa7602fd1..8ea1cd3e587a86356fdbd6761e580b8024c0e01e 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -87,6 +87,7 @@ function poll_cron() { function poll_delete($node) { db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid); db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid); + db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid); } /** @@ -482,6 +483,7 @@ function poll_update($node) { db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid); db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid); foreach ($node->choice as $choice) { $chvotes = (int)$choice['chvotes']; $chtext = $choice['chtext'];