OKAPI Project update (r424).

The major difference in this version of OKAPI is that it properly hides caches with statuses > 3. However, this required a complex update process. I'm not 100% sure if this update process will succeed in all scenarios, but I think it should.

Note, that first cronjobs fired after this update MAY take even 20 minutes to run.
This commit is contained in:
Wojciech Rygielski
2012-08-23 10:51:12 +02:00
parent b7ae9cc1f0
commit bdc794952e
16 changed files with 599 additions and 60 deletions

View File

@ -139,7 +139,7 @@ class View
print "please contact me - rygielski@mimuw.edu.pl.\n\n";
print "-- \n";
print "Wojciech Rygielski, OKAPI developer";
Okapi::mail_admins("Database modification notice: cache_logs.last_modified", ob_get_clean());
Okapi::mail_admins("Starting OKAPI installation", ob_get_clean());
Db::execute("
CREATE TABLE okapi_vars (
@ -416,34 +416,117 @@ class View
private static function ver51()
{
Db::execute("alter table cache_logs modify column last_modified timestamp not null;");
ob_start();
print "Hi!\n\n";
print "OKAPI just modified 'last_modified' field in your 'cache_logs' table.\n";
print "Its type was changed to 'timestamp'. It is required by OKAPI's 'replicate'\n";
print "module to function properly.\n\n";
self::print_common_db_alteration_info();
print "-- \n";
print "OKAPI Team";
Okapi::mail_admins("Database modification notice: cache_logs.last_modified", ob_get_clean());
# Before revision 417, OKAPI used to make the following change:
# - Db::execute("alter table cache_logs modify column last_modified timestamp not null;");
# It doesn't do that anymore. Instead, it adds a separate column for itself (okapi_syncbase).
}
private static function ver52()
{
# Before revision 417, OKAPI used to make the following change (on OCDE branch):
# - Db::execute("alter table cache_logs_archived modify column last_modified timestamp not null;");
# It doesn't do that anymore. Instead, it adds a separate column for itself (okapi_syncbase).
}
private static function ver53() { Db::execute("alter table cache_logs add column okapi_syncbase timestamp not null after last_modified;"); }
private static function ver54() { Db::execute("update cache_logs set okapi_syncbase=last_modified;"); }
private static function ver55()
{
if (Settings::get('OC_BRANCH') == 'oc.pl')
{
# OCPL does not have cache_logs_archived table.
return;
}
Db::execute("alter table cache_logs_archived modify column last_modified timestamp not null;");
Db::execute("alter table cache_logs_archived add column okapi_syncbase timestamp not null after last_modified;");
}
private static function ver56()
{
if (Settings::get('OC_BRANCH') == 'oc.pl')
{
# OCPL does not have cache_logs_archived table.
return;
}
Db::execute("update cache_logs_archived set okapi_syncbase=last_modified;");
}
private static function ver57()
{
ob_start();
print "Hi!\n\n";
print "OKAPI just modified 'last_modified' field in your 'cache_logs_archived' table.\n";
print "Its type was changed to 'timestamp'. It is required by OKAPI's 'replicate'\n";
print "module to function properly.\n\n";
print "OKAPI just added additional field (along with an index) 'okapi_syncbase'\n";
print "on your 'cache_logs' AND 'cache_logs_archived' tables. It is required by\n";
print "OKAPI's 'replicate' module to function properly.\n\n";
self::print_common_db_alteration_info();
print "-- \n";
print "OKAPI Team";
Okapi::mail_admins("Database modification notice: cache_logs_archived.last_modified", ob_get_clean());
Okapi::mail_admins("Database modification notice: caches.okapi_syncbase", ob_get_clean());
}
private static function ver58()
{
#
# Starting with revision 417, OKAPI hides all caches with statuses > 3.
# Hence, we need such caches to be removed from external databases replicated
# via the "replicate" module. By reseting the "okapi_syncbase" timestamp,
# we force changelog generator cronjob to issue proper "delete" statements
# to the changelog.
#
Db::execute("
update caches
set okapi_syncbase = now()
where status > 3
");
}
private static function ver59()
{
# As above.
Db::execute("
update
cache_logs cl,
caches c
set cl.okapi_syncbase = now()
where
cl.cache_id = c.cache_id
and c.status > 3
");
}
private static function ver60()
{
# Turns out there can be only one valid TIMESTAMP field in one table!
# Fields added ver53-ver59 don't work properly *if* ver51-ver52 had been run.
#
# We'll check if ver51-ver52 had been run and try to withdraw it AND
# *rerun* missing ver53-ver59 updates.
#
$row = Db::select_row("show create table cache_logs");
$stmt = $row["Create Table"];
if (strpos($stmt, "timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'") > 0)
{
Db::execute("alter table cache_logs modify column last_modified datetime not null;");
Db::execute("alter table cache_logs modify column okapi_syncbase timestamp not null;");
Db::execute("update cache_logs set okapi_syncbase=now() where okapi_syncbase='0000-00-00 00:00:00';");
if (Settings::get('OC_BRANCH') == 'oc.de')
{
Db::execute("alter table cache_logs_archived modify column last_modified datetime not null;");
Db::execute("alter table cache_logs_archived modify column okapi_syncbase timestamp not null;");
Db::execute("update cache_logs_archived set okapi_syncbase=now() where okapi_syncbase='0000-00-00 00:00:00';");
}
}
}
private static function ver61() { Db::execute("alter table cache_logs add key okapi_syncbase (okapi_syncbase);"); }
private static function ver62()
{
if (Settings::get('OC_BRANCH') == 'oc.pl')
{
# OCPL does not have cache_logs_archived table.
return;
}
Db::execute("alter table cache_logs_archived add key okapi_syncbase (okapi_syncbase);");
}
}