From e415bd3fcade564cdcb1654cdbcb6185fb082947 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 9 Aug 2015 12:16:06 +0100 Subject: [PATCH] more database support --- ext/blotter/main.php | 4 ++-- ext/ipban/main.php | 2 +- ext/pm/main.php | 2 +- ext/rating/main.php | 1 + ext/relatationships/main.php | 5 +++-- ext/tag_categories/main.php | 21 +++++++++++++++------ ext/tips/main.php | 2 ++ 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ext/blotter/main.php b/ext/blotter/main.php index 8460932c..a0bd21b5 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -32,8 +32,8 @@ class Blotter extends Extension { important SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N "); // Insert sample data: - $database->execute("INSERT INTO blotter (id, entry_date, entry_text, important) VALUES (?, now(), ?, ?)", - array(NULL, "Installed the blotter extension!", "Y")); + $database->execute("INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), ?, ?)", + array("Installed the blotter extension!", "Y")); log_info("blotter", "Installed tables for blotter extension."); $config->set_int("blotter_version", 1); } diff --git a/ext/ipban/main.php b/ext/ipban/main.php index 362650b7..b64511dc 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -120,9 +120,9 @@ class IPBan extends Extension { end_timestamp INTEGER, reason TEXT NOT NULL, added SCORE_DATETIME NOT NULL DEFAULT SCORE_NOW, - INDEX (end_timestamp), FOREIGN KEY (banner_id) REFERENCES users(id) ON DELETE CASCADE, "); + $database->execute("CREATE INDEX bans__end_timestamp ON bans(end_timestamp)"); $config->set_int("ext_ipban_version", 8); } diff --git a/ext/pm/main.php b/ext/pm/main.php index 4c002444..a0bb8c7e 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -61,10 +61,10 @@ class PrivMsg extends Extension { subject VARCHAR(64) NOT NULL, message TEXT NOT NULL, is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, - INDEX (to_id), FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, 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", 2); log_info("pm", "extension installed"); } diff --git a/ext/rating/main.php b/ext/rating/main.php index f53249e2..5177e3fc 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -38,6 +38,7 @@ class RatingSetEvent extends Event { } class Ratings extends Extension { + public $db_support = ['mysql']; // ? /** * @return int diff --git a/ext/relatationships/main.php b/ext/relatationships/main.php index 87697c31..9126a816 100644 --- a/ext/relatationships/main.php +++ b/ext/relatationships/main.php @@ -14,8 +14,9 @@ class Relationships extends Extension { // Create the database tables if ($config->get_int("ext_relationships_version") < 1){ - $database->Execute("ALTER TABLE images ADD parent_id INT NULL, ADD INDEX (parent_id);"); - $database->Execute("ALTER TABLE images ADD has_children BOOL DEFAULT FALSE NOT NULL;"); + $database->execute("ALTER TABLE images ADD parent_id INT"); + $database->execute($database->scoreql_to_sql("ALTER TABLE images ADD has_children SCORE_BOOL DEFAULT SCORE_BOOL_N NOT NULL")); + $database->execute("CREATE INDEX images__parent_id ON images(parent_id)"); $config->set_int("ext_relationships_version", 1); log_info("relationships", "extension installed"); diff --git a/ext/tag_categories/main.php b/ext/tag_categories/main.php index 4e0fbdda..1ab52af1 100644 --- a/ext/tag_categories/main.php +++ b/ext/tag_categories/main.php @@ -18,9 +18,9 @@ class TagCategories extends Extension { // primary extension database, holds all our stuff! $database->create_table('image_tag_categories', 'category VARCHAR(60) PRIMARY KEY, - display_singular TEXT(60), - display_multiple TEXT(60), - color TEXT(7)'); + display_singular VARCHAR(60), + display_multiple VARCHAR(60), + color VARCHAR(7)'); $config->set_int("ext_tag_categories_version", 1); @@ -31,9 +31,18 @@ class TagCategories extends Extension { $number_of_db_rows = $database->execute('SELECT COUNT(*) FROM image_tag_categories;')->fetchColumn(); if ($number_of_db_rows == 0) { - $database->execute('INSERT INTO image_tag_categories VALUES ("artist", "Artist", "Artists", "#BB6666");'); - $database->execute('INSERT INTO image_tag_categories VALUES ("series", "Series", "Series", "#AA00AA");'); - $database->execute('INSERT INTO image_tag_categories VALUES ("character", "Character", "Characters", "#66BB66");'); + $database->execute( + 'INSERT INTO image_tag_categories VALUES (?, ?, ?, ?)', + array("artist", "Artist", "Artists", "#BB6666") + ); + $database->execute( + 'INSERT INTO image_tag_categories VALUES (?, ?, ?, ?)', + array("series", "Series", "Series", "#AA00AA") + ); + $database->execute( + 'INSERT INTO image_tag_categories VALUES (?, ?, ?, ?)', + array("character", "Character", "Characters", "#66BB66") + ); } } diff --git a/ext/tips/main.php b/ext/tips/main.php index ca1753db..4c6ab6a3 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -9,6 +9,8 @@ */ class Tips extends Extension { + public $db_support = ['mysql', 'sqlite']; // rand() ? + public function onInitExt(InitExtEvent $event) { global $config, $database;