Set column defaults
This commit is contained in:
parent
aa5a04fbd3
commit
e065c8b789
@ -532,7 +532,7 @@ class Ratings extends Extension
|
|||||||
global $database, $config;
|
global $database, $config;
|
||||||
|
|
||||||
if ($config->get_int(RatingsConfig::VERSION) < 1) {
|
if ($config->get_int(RatingsConfig::VERSION) < 1) {
|
||||||
$database->Execute("ALTER TABLE images ADD COLUMN rating CHAR(1) NOT NULL DEFAULT 'u'");
|
$database->Execute("ALTER TABLE images ADD COLUMN rating CHAR(1) NOT NULL DEFAULT '?'");
|
||||||
$database->Execute("CREATE INDEX images__rating ON images(rating)");
|
$database->Execute("CREATE INDEX images__rating ON images(rating)");
|
||||||
$config->set_int(RatingsConfig::VERSION, 3);
|
$config->set_int(RatingsConfig::VERSION, 3);
|
||||||
}
|
}
|
||||||
@ -565,9 +565,19 @@ class Ratings extends Extension
|
|||||||
$config->set_array("ext_rating_admin_privs", str_split($value));
|
$config->set_array("ext_rating_admin_privs", str_split($value));
|
||||||
|
|
||||||
|
|
||||||
|
switch ($database->get_driver_name()) {
|
||||||
|
case DatabaseDriver::MYSQL:
|
||||||
|
$database->Execute("ALTER TABLE images CHANGE rating rating CHAR(1) NOT NULL DEFAULT '?'");
|
||||||
|
break;
|
||||||
|
case DatabaseDriver::PGSQL:
|
||||||
|
$database->Execute("ALTER TABLE images ALTER COLUMN rating SET DEFAULT '?'");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ($database->get_driver_name()==DatabaseDriver::PGSQL) { // These updates can take a little bit
|
if ($database->get_driver_name()==DatabaseDriver::PGSQL) { // These updates can take a little bit
|
||||||
$database->execute("SET statement_timeout TO 300000;");
|
$database->execute("SET statement_timeout TO 300000;");
|
||||||
}
|
}
|
||||||
|
|
||||||
$database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new"=>'?', "old"=>'u' ]);
|
$database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new"=>'?', "old"=>'u' ]);
|
||||||
|
|
||||||
$config->set_int(RatingsConfig::VERSION, 4);
|
$config->set_int(RatingsConfig::VERSION, 4);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user