Skip to content

Commit

Permalink
[pools] remove mysql-specific bits
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Aug 18, 2023
1 parent 1cef09f commit 867fdec
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions ext/pools/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
id SCORE_AIPK,
user_id INTEGER NOT NULL,
public BOOLEAN NOT NULL DEFAULT FALSE,
title VARCHAR(255) NOT NULL,
title VARCHAR(255) NOT NULL UNIQUE,
description TEXT,
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
lastupdated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
posts INTEGER NOT NULL DEFAULT 0,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
");
Expand All @@ -164,12 +165,6 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
log_info("pools", "extension installed");
}

if ($this->get_version("ext_pools_version") < 2) {
$database->execute("ALTER TABLE pools ADD UNIQUE INDEX (title);");
$database->execute("ALTER TABLE pools ADD lastupdated TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;");

$this->set_version("ext_pools_version", 3); // skip 2
}
if ($this->get_version("ext_pools_version") < 4) {
$database->standardise_boolean("pools", "public");
$this->set_version("ext_pools_version", 4);
Expand Down Expand Up @@ -403,7 +398,7 @@ public function onPageRequest(PageRequestEvent $event)
case "edit_description":
if ($this->have_permission($user, $pool)) {
$database->execute(
"UPDATE pools SET description=:dsc WHERE id=:pid",
"UPDATE pools SET description=:dsc,lastupdated=CURRENT_TIMESTAMP WHERE id=:pid",
["dsc" => $_POST['description'], "pid" => $pool_id]
);
$page->set_mode(PageMode::REDIRECT);
Expand Down Expand Up @@ -983,7 +978,7 @@ private function update_count(int $pool_id)
{
global $database;
$database->execute(
"UPDATE pools SET posts=(SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid) WHERE id=:pid",
"UPDATE pools SET posts=(SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid),lastupdated=CURRENT_TIMESTAMP WHERE id=:pid",
["pid" => $pool_id]
);
}
Expand Down

0 comments on commit 867fdec

Please sign in to comment.