forked from Cavemanon/cavepaintings
use get_version instead of get_int for versions
This commit is contained in:
parent
b9e1ce1b8d
commit
b4c4de58a2
@ -15,9 +15,9 @@ class Blotter extends Extension
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
global $database;
|
||||
|
||||
if ($config->get_int("blotter_version", 0) < 1) {
|
||||
if ($this->get_version("blotter_version") < 1) {
|
||||
$database->create_table("blotter", "
|
||||
id SCORE_AIPK,
|
||||
entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
@ -30,11 +30,11 @@ class Blotter extends Extension
|
||||
["text"=>"Installed the blotter extension!", "important"=>true]
|
||||
);
|
||||
log_info("blotter", "Installed tables for blotter extension.");
|
||||
$config->set_int("blotter_version", 2);
|
||||
$this->set_version("blotter_version", 2);
|
||||
}
|
||||
if ($config->get_int("blotter_version") < 2) {
|
||||
if ($this->get_version("blotter_version") < 2) {
|
||||
$database->standardise_boolean("blotter", "important");
|
||||
$config->set_int("blotter_version", 2);
|
||||
$this->set_version("blotter_version", 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,17 +35,16 @@ class ETServer extends Extension
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
global $database;
|
||||
|
||||
// shortcut to latest
|
||||
if ($config->get_int("et_server_version") < 1) {
|
||||
if ($this->get_version("et_server_version") < 1) {
|
||||
$database->create_table("registration", "
|
||||
id SCORE_AIPK,
|
||||
responded TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
data TEXT NOT NULL,
|
||||
");
|
||||
$config->set_int("et_server_version", 1);
|
||||
log_info("et_server", "extension installed");
|
||||
$this->set_version("et_server_version", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class Forum extends Extension
|
||||
|
||||
// shortcut to latest
|
||||
|
||||
if ($config->get_int("forum_version") < 1) {
|
||||
if ($this->get_version("forum_version") < 1) {
|
||||
$database->create_table("forum_threads", "
|
||||
id SCORE_AIPK,
|
||||
sticky BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
@ -47,17 +47,16 @@ class Forum extends Extension
|
||||
|
||||
$config->set_int("forumMaxCharsPerPost", 512);
|
||||
|
||||
$config->set_int("forum_version", 3);
|
||||
log_info("forum", "extension installed");
|
||||
$this->set_version("forum_version", 3);
|
||||
}
|
||||
if ($config->get_int("forum_version") < 2) {
|
||||
if ($this->get_version("forum_version") < 2) {
|
||||
$database->execute("ALTER TABLE forum_threads ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT");
|
||||
$database->execute("ALTER TABLE forum_posts ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT");
|
||||
$config->set_int("forum_version", 2);
|
||||
$this->set_version("forum_version", 2);
|
||||
}
|
||||
if ($config->get_int("forum_version") < 3) {
|
||||
if ($this->get_version("forum_version") < 3) {
|
||||
$database->standardise_boolean("forum_threads", "sticky");
|
||||
$config->set_int("forum_version", 3);
|
||||
$this->set_version("forum_version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,10 +62,10 @@ class PrivMsg extends Extension
|
||||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
global $database;
|
||||
|
||||
// shortcut to latest
|
||||
if ($config->get_int("pm_version") < 1) {
|
||||
if ($this->get_version("pm_version") < 1) {
|
||||
$database->create_table("private_message", "
|
||||
id SCORE_AIPK,
|
||||
from_id INTEGER NOT NULL,
|
||||
@ -79,26 +79,22 @@ class PrivMsg extends Extension
|
||||
FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
");
|
||||
$database->execute("CREATE INDEX private_message__to_id ON private_message(to_id)");
|
||||
$config->set_int("pm_version", 3);
|
||||
log_info("pm", "extension installed");
|
||||
$this->set_version("pm_version", 3);
|
||||
}
|
||||
|
||||
if ($config->get_int("pm_version") < 2) {
|
||||
if ($this->get_version("pm_version") < 2) {
|
||||
log_info("pm", "Adding foreign keys to private messages");
|
||||
$database->execute("delete from private_message where to_id not in (select id from users);");
|
||||
$database->execute("delete from private_message where from_id not in (select id from users);");
|
||||
$database->execute("ALTER TABLE private_message
|
||||
ADD FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
ADD FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;");
|
||||
$config->set_int("pm_version", 2);
|
||||
log_info("pm", "extension upgraded");
|
||||
$this->set_version("pm_version", 2);
|
||||
}
|
||||
|
||||
if ($config->get_int("pm_version") < 3) {
|
||||
log_info("pm", "Updating is_read boolean");
|
||||
if ($this->get_version("pm_version") < 3) {
|
||||
$database->standardise_boolean("private_message", "is_read", true);
|
||||
$config->set_int("pm_version", 3);
|
||||
log_info("pm", "extension upgraded");
|
||||
$this->set_version("pm_version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ class Upgrade extends Extension
|
||||
file_put_contents("data/index.php", "<?php\n// Silence is golden...\n");
|
||||
}
|
||||
|
||||
if ($config->get_int("db_version") < 1) {
|
||||
if ($this->get_version("db_version") < 1) {
|
||||
$this->set_version("db_version", 2);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user