LP#1288938: Leaking URIs ... don't do that

Ben Shum spotted an issue where the old behavior
could leak hidden URIs.  Being more explicit in the
WHERE clause addresses this.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
LP1288938 - stamping upgrade script

With minor fixing to remove the unneeded bits of the upgrade scripts.

Signed-off-by: Ben Shum <bshum@biblio.org>