[dw-free] remove legacy database tables
[commit: http://hg.dwscoalition.org/dw-free/rev/a907ed584e44]
http://bugs.dwscoalition.org/show_bug.cgi?id=1710
Remove obsolete poll tables.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1710
Remove obsolete poll tables.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/update-db-general.pl
- cgi-bin/LJ/CProd/Polls.pm
- cgi-bin/LJ/Poll.pm
- cgi-bin/ljlib.pl
-------------------------------------------------------------------------------- diff -r 4adaa4a856ec -r a907ed584e44 bin/upgrading/update-db-general.pl --- a/bin/upgrading/update-db-general.pl Fri Sep 11 14:20:57 2009 +0000 +++ b/bin/upgrading/update-db-general.pl Fri Sep 11 14:36:06 2009 +0000 @@ -258,71 +258,6 @@ CREATE TABLE pendcomments ( PRIMARY KEY (pendcid, jid), KEY (datesubmit) -) -EOC - -register_tablecreate("poll", <<'EOC'); -CREATE TABLE poll ( - pollid int(10) unsigned NOT NULL auto_increment, - itemid int(10) unsigned NOT NULL default '0', - journalid int(10) unsigned NOT NULL default '0', - posterid int(10) unsigned NOT NULL default '0', - whovote enum('all','friends') NOT NULL default 'all', - whoview enum('all','friends','none') NOT NULL default 'all', - name varchar(255) default NULL, - - PRIMARY KEY (pollid), - KEY (itemid), - KEY (journalid), - KEY (posterid) -) -EOC - -register_tablecreate("pollitem", <<'EOC'); -CREATE TABLE pollitem ( - pollid int(10) unsigned NOT NULL default '0', - pollqid tinyint(3) unsigned NOT NULL default '0', - pollitid tinyint(3) unsigned NOT NULL default '0', - sortorder tinyint(3) unsigned NOT NULL default '0', - item varchar(255) default NULL, - - PRIMARY KEY (pollid,pollqid,pollitid) -) -EOC - -register_tablecreate("pollquestion", <<'EOC'); -CREATE TABLE pollquestion ( - pollid int(10) unsigned NOT NULL default '0', - pollqid tinyint(3) unsigned NOT NULL default '0', - sortorder tinyint(3) unsigned NOT NULL default '0', - type enum('check','radio','drop','text','scale') default NULL, - opts varchar(20) default NULL, - qtext text, - - PRIMARY KEY (pollid,pollqid) -) -EOC - -register_tablecreate("pollresult", <<'EOC'); -CREATE TABLE pollresult ( - pollid int(10) unsigned NOT NULL default '0', - pollqid tinyint(3) unsigned NOT NULL default '0', - userid int(10) unsigned NOT NULL default '0', - value varchar(255) default NULL, - - PRIMARY KEY (pollid,pollqid,userid), - KEY (pollid,userid) -) -EOC - -register_tablecreate("pollsubmission", <<'EOC'); -CREATE TABLE pollsubmission ( - pollid int(10) unsigned NOT NULL default '0', - userid int(10) unsigned NOT NULL default '0', - datesubmit datetime NOT NULL default '0000-00-00 00:00:00', - - PRIMARY KEY (pollid,userid), - KEY (userid) ) EOC @@ -967,6 +902,11 @@ register_tabledrop("syndicated_hubbub"); register_tabledrop("syndicated_hubbub"); register_tabledrop("oldids"); register_tabledrop("keywords"); +register_tabledrop("poll"); +register_tabledrop("pollitem"); +register_tabledrop("pollquestion"); +register_tabledrop("pollresult"); +register_tabledrop("pollsubmission"); register_tablecreate("portal", <<'EOC'); CREATE TABLE portal ( @@ -3732,11 +3672,6 @@ register_alter(sub { } # add a status column to polls - unless (column_type("poll", "status")) { - do_alter("poll", - "ALTER TABLE poll ADD status CHAR(1) AFTER name, " . - "ADD INDEX (status)"); - } unless (column_type("poll2", "status")) { do_alter("poll2", "ALTER TABLE poll2 ADD status CHAR(1) AFTER name, " . @@ -3870,13 +3805,6 @@ register_alter(sub { "ALTER TABLE acctcode ADD timesent INT UNSIGNED"); } - unless ( column_type( "poll", "whovote" ) =~ /trusted/ ) { - do_alter("poll", - "ALTER TABLE poll MODIFY COLUMN whovote ENUM('all','trusted','ofentry') NOT NULL default 'all'" ); - do_alter("poll", - "ALTER TABLE poll MODIFY COLUMN whoview ENUM('all','trusted','ofentry','none') NOT NULL default 'all'" ); - } - unless ( column_type( "poll2", "whovote" ) =~ /trusted/ ) { do_alter("poll2", "ALTER TABLE poll2 MODIFY COLUMN whovote ENUM('all','trusted','ofentry') NOT NULL default 'all'" ); diff -r 4adaa4a856ec -r a907ed584e44 cgi-bin/LJ/CProd/Polls.pm --- a/cgi-bin/LJ/CProd/Polls.pm Fri Sep 11 14:20:57 2009 +0000 +++ b/cgi-bin/LJ/CProd/Polls.pm Fri Sep 11 14:36:06 2009 +0000 @@ -4,10 +4,10 @@ sub applicable { sub applicable { my ($class, $u) = @_; return 0 unless LJ::get_cap($u, "makepoll"); - my $dbr = LJ::get_db_reader() + my $dbcr = LJ::get_cluster_reader( $u ) or return 0; - my $used_polls = $dbr->selectrow_array("SELECT pollid FROM poll WHERE posterid=?", - undef, $u->{userid}); + my $used_polls = $dbcr->selectrow_array( "SELECT pollid FROM poll2 WHERE posterid=?", + undef, $u->userid ); return $used_polls ? 0 : 1; } diff -r 4adaa4a856ec -r a907ed584e44 cgi-bin/LJ/Poll.pm --- a/cgi-bin/LJ/Poll.pm Fri Sep 11 14:20:57 2009 +0000 +++ b/cgi-bin/LJ/Poll.pm Fri Sep 11 14:36:06 2009 +0000 @@ -547,23 +547,14 @@ sub _load { my $row = ''; - unless ($journalid) { - # this is probably not clustered, check global - $row = $dbr->selectrow_hashref("SELECT pollid, itemid, journalid, " . - "posterid, whovote, whoview, name, status " . - "FROM poll WHERE pollid=?", undef, $self->pollid); - die $dbr->errstr if $dbr->err; - } else { - my $u = LJ::load_userid($journalid) - or die "Invalid journalid $journalid"; + my $u = LJ::load_userid( $journalid ) + or die "Invalid journalid $journalid"; - # double-check to make sure we are consulting the right table - $row = $u->selectrow_hashref( "SELECT pollid, journalid, ditemid, " . - "posterid, whovote, whoview, name, status " . - "FROM poll2 WHERE pollid=? " . - "AND journalid=?", undef, $self->pollid, $journalid ); - die $u->errstr if $u->err; - } + $row = $u->selectrow_hashref( "SELECT pollid, journalid, ditemid, " . + "posterid, whovote, whoview, name, status " . + "FROM poll2 WHERE pollid=? " . + "AND journalid=?", undef, $self->pollid, $journalid ); + die $u->errstr if $u->err; return undef unless $row; diff -r 4adaa4a856ec -r a907ed584e44 cgi-bin/ljlib.pl --- a/cgi-bin/ljlib.pl Fri Sep 11 14:20:57 2009 +0000 +++ b/cgi-bin/ljlib.pl Fri Sep 11 14:36:06 2009 +0000 @@ -2118,10 +2118,8 @@ sub alloc_global_counter } elsif ($dom eq "H") { $newmax = $dbh->selectrow_array("SELECT MAX(cartid) FROM shop_carts"); } elsif ($dom eq "L") { - # pick maximum id from poll and pollowner - my $max_poll = $dbh->selectrow_array("SELECT MAX(pollid) FROM poll"); - my $max_pollowner = $dbh->selectrow_array("SELECT MAX(pollid) FROM pollowner"); - $newmax = $max_poll > $max_pollowner ? $max_poll : $max_pollowner; + # pick maximum id from pollowner + $newmax = $dbh->selectrow_array( "SELECT MAX(pollid) FROM pollowner" ); } elsif ( $dom eq 'F' ) { $newmax = $dbh->selectrow_array( 'SELECT MAX(id) FROM syndicated_hubbub2' ); } else { --------------------------------------------------------------------------------