This commit is contained in:
Shish 2019-11-03 18:28:16 +00:00
commit 427acc55a0
16 changed files with 33 additions and 40 deletions

View file

@ -279,7 +279,7 @@ EOD;
id SCORE_AIPK, id SCORE_AIPK,
name VARCHAR(32) UNIQUE NOT NULL, name VARCHAR(32) UNIQUE NOT NULL,
pass VARCHAR(250), pass VARCHAR(250),
joindate SCORE_DATETIME NOT NULL DEFAULT SCORE_NOW, joindate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
class VARCHAR(32) NOT NULL DEFAULT 'user', class VARCHAR(32) NOT NULL DEFAULT 'user',
email VARCHAR(128) email VARCHAR(128)
"); ");
@ -296,7 +296,7 @@ EOD;
source VARCHAR(255), source VARCHAR(255),
width INTEGER NOT NULL, width INTEGER NOT NULL,
height INTEGER NOT NULL, height INTEGER NOT NULL,
posted SCORE_DATETIME NOT NULL DEFAULT SCORE_NOW, posted TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
"); ");

View file

@ -6,8 +6,6 @@ abstract class SCORE
const BOOL_Y = "SCORE_BOOL_Y"; const BOOL_Y = "SCORE_BOOL_Y";
const BOOL_N = "SCORE_BOOL_N"; const BOOL_N = "SCORE_BOOL_N";
const BOOL = "SCORE_BOOL"; const BOOL = "SCORE_BOOL";
const DATETIME = "SCORE_DATETIME";
const NOW = "SCORE_NOW";
const STRNORM = "SCORE_STRNORM"; const STRNORM = "SCORE_STRNORM";
const ILIKE = "SCORE_ILIKE"; const ILIKE = "SCORE_ILIKE";
} }
@ -57,8 +55,6 @@ class MySQL extends DBEngine
$data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data); $data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data);
$data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data); $data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data);
$data = str_replace(SCORE::BOOL, "ENUM('Y', 'N')", $data); $data = str_replace(SCORE::BOOL, "ENUM('Y', 'N')", $data);
$data = str_replace(SCORE::DATETIME, "DATETIME", $data);
$data = str_replace(SCORE::NOW, "\"1970-01-01\"", $data);
$data = str_replace(SCORE::STRNORM, "", $data); $data = str_replace(SCORE::STRNORM, "", $data);
$data = str_replace(SCORE::ILIKE, "LIKE", $data); $data = str_replace(SCORE::ILIKE, "LIKE", $data);
return $data; return $data;
@ -105,8 +101,6 @@ class PostgreSQL extends DBEngine
$data = str_replace(SCORE::BOOL_Y, $this->BOOL_Y, $data); $data = str_replace(SCORE::BOOL_Y, $this->BOOL_Y, $data);
$data = str_replace(SCORE::BOOL_N, $this->BOOL_N, $data); $data = str_replace(SCORE::BOOL_N, $this->BOOL_N, $data);
$data = str_replace(SCORE::BOOL, "BOOL", $data); $data = str_replace(SCORE::BOOL, "BOOL", $data);
$data = str_replace(SCORE::DATETIME, "TIMESTAMP", $data);
$data = str_replace(SCORE::NOW, "current_timestamp", $data);
$data = str_replace(SCORE::STRNORM, "lower", $data); $data = str_replace(SCORE::STRNORM, "lower", $data);
$data = str_replace(SCORE::ILIKE, "ILIKE", $data); $data = str_replace(SCORE::ILIKE, "ILIKE", $data);
return $data; return $data;
@ -202,7 +196,6 @@ class SQLite extends DBEngine
$data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data); $data = str_replace(SCORE::BOOL_Y, "'$this->BOOL_Y'", $data);
$data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data); $data = str_replace(SCORE::BOOL_N, "'$this->BOOL_N'", $data);
$data = str_replace(SCORE::BOOL, "CHAR(1)", $data); $data = str_replace(SCORE::BOOL, "CHAR(1)", $data);
$data = str_replace(SCORE::NOW, "\"1970-01-01\"", $data);
$data = str_replace(SCORE::STRNORM, "lower", $data); $data = str_replace(SCORE::STRNORM, "lower", $data);
$data = str_replace(SCORE::ILIKE, "LIKE", $data); $data = str_replace(SCORE::ILIKE, "LIKE", $data);
return $data; return $data;

View file

@ -65,8 +65,8 @@ class Artists extends Extension
id SCORE_AIPK, id SCORE_AIPK,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
created SCORE_DATETIME NOT NULL, created TIMESTAMP NOT NULL,
updated SCORE_DATETIME NOT NULL, updated TIMESTAMP NOT NULL,
notes TEXT, notes TEXT,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
"); ");
@ -76,8 +76,8 @@ class Artists extends Extension
artist_id INTEGER NOT NULL, artist_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
created SCORE_DATETIME NOT NULL, created TIMESTAMP NOT NULL,
updated SCORE_DATETIME NOT NULL, updated TIMESTAMP NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
"); ");
@ -85,8 +85,8 @@ class Artists extends Extension
id SCORE_AIPK, id SCORE_AIPK,
artist_id INTEGER NOT NULL, artist_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
created SCORE_DATETIME, created TIMESTAMP,
updated SCORE_DATETIME, updated TIMESTAMP,
alias VARCHAR(255), alias VARCHAR(255),
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
@ -95,8 +95,8 @@ class Artists extends Extension
id SCORE_AIPK, id SCORE_AIPK,
artist_id INTEGER NOT NULL, artist_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
created SCORE_DATETIME NOT NULL, created TIMESTAMP NOT NULL,
updated SCORE_DATETIME NOT NULL, updated TIMESTAMP NOT NULL,
url VARCHAR(1000) NOT NULL, url VARCHAR(1000) NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE

View file

@ -26,7 +26,7 @@ class Blotter extends Extension
global $database, $config; global $database, $config;
$database->create_table("blotter", " $database->create_table("blotter", "
id SCORE_AIPK, id SCORE_AIPK,
entry_date SCORE_DATETIME DEFAULT SCORE_NOW, entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
entry_text TEXT NOT NULL, entry_text TEXT NOT NULL,
important SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N important SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N
"); ");

View file

@ -110,7 +110,7 @@ class CommentList extends Extension
image_id INTEGER NOT NULL, image_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL, owner_id INTEGER NOT NULL,
owner_ip SCORE_INET NOT NULL, owner_ip SCORE_INET NOT NULL,
posted SCORE_DATETIME DEFAULT NULL, posted TIMESTAMP DEFAULT NULL,
comment TEXT NOT NULL, comment TEXT NOT NULL,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
@ -128,7 +128,7 @@ class CommentList extends Extension
image_id INTEGER NOT NULL, image_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL, owner_id INTEGER NOT NULL,
owner_ip CHAR(16) NOT NULL, owner_ip CHAR(16) NOT NULL,
posted SCORE_DATETIME DEFAULT NULL, posted TIMESTAMP DEFAULT NULL,
comment TEXT NOT NULL comment TEXT NOT NULL
"); ");
$database->execute("CREATE INDEX comments_image_id_idx ON comments(image_id)", []); $database->execute("CREATE INDEX comments_image_id_idx ON comments(image_id)", []);

View file

@ -208,7 +208,7 @@ class Favorites extends Extension
$database->create_table("user_favorites", " $database->create_table("user_favorites", "
image_id INTEGER NOT NULL, image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
created_at SCORE_DATETIME NOT NULL, created_at TIMESTAMP NOT NULL,
UNIQUE(image_id, user_id), UNIQUE(image_id, user_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE

View file

@ -21,8 +21,8 @@ class Forum extends Extension
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
date SCORE_DATETIME NOT NULL, date TIMESTAMP NOT NULL,
uptodate SCORE_DATETIME NOT NULL, uptodate TIMESTAMP NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT
"); ");
$database->execute("CREATE INDEX forum_threads_date_idx ON forum_threads(date)", []); $database->execute("CREATE INDEX forum_threads_date_idx ON forum_threads(date)", []);
@ -31,7 +31,7 @@ class Forum extends Extension
id SCORE_AIPK, id SCORE_AIPK,
thread_id INTEGER NOT NULL, thread_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
date SCORE_DATETIME NOT NULL, date TIMESTAMP NOT NULL,
message TEXT, message TEXT,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE

View file

@ -31,7 +31,7 @@ class ImageBan extends Extension
$database->create_table("image_bans", " $database->create_table("image_bans", "
id SCORE_AIPK, id SCORE_AIPK,
hash CHAR(32) NOT NULL, hash CHAR(32) NOT NULL,
date SCORE_DATETIME DEFAULT SCORE_NOW, date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
reason TEXT NOT NULL reason TEXT NOT NULL
"); ");
$config->set_int("ext_imageban_version", 1); $config->set_int("ext_imageban_version", 1);

View file

@ -138,7 +138,7 @@ class IPBan extends Extension
ip SCORE_INET NOT NULL, ip SCORE_INET NOT NULL,
end_timestamp INTEGER, end_timestamp INTEGER,
reason TEXT NOT NULL, reason TEXT NOT NULL,
added SCORE_DATETIME NOT NULL DEFAULT SCORE_NOW, added TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (banner_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (banner_id) REFERENCES users(id) ON DELETE CASCADE,
"); ");
$database->execute("CREATE INDEX bans__end_timestamp ON bans(end_timestamp)"); $database->execute("CREATE INDEX bans__end_timestamp ON bans(end_timestamp)");
@ -151,8 +151,8 @@ class IPBan extends Extension
$database->Execute("CREATE TABLE bans ( $database->Execute("CREATE TABLE bans (
id int(11) NOT NULL auto_increment, id int(11) NOT NULL auto_increment,
ip char(15) default NULL, ip char(15) default NULL,
date SCORE_DATETIME default NULL, date TIMESTAMP default NULL,
end SCORE_DATETIME default NULL, end TIMESTAMP default NULL,
reason varchar(255) default NULL, reason varchar(255) default NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
)"); )");
@ -198,7 +198,7 @@ class IPBan extends Extension
if ($config->get_int("ext_ipban_version") == 7) { if ($config->get_int("ext_ipban_version") == 7) {
$database->execute($database->scoreql_to_sql("ALTER TABLE bans CHANGE ip ip SCORE_INET")); $database->execute($database->scoreql_to_sql("ALTER TABLE bans CHANGE ip ip SCORE_INET"));
$database->execute($database->scoreql_to_sql("ALTER TABLE bans ADD COLUMN added SCORE_DATETIME NOT NULL DEFAULT SCORE_NOW")); $database->execute($database->scoreql_to_sql("ALTER TABLE bans ADD COLUMN added TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"));
$config->set_int("ext_ipban_version", 8); $config->set_int("ext_ipban_version", 8);
} }

View file

@ -14,7 +14,7 @@ class LogDatabase extends Extension
if ($config->get_int("ext_log_database_version") < 1) { if ($config->get_int("ext_log_database_version") < 1) {
$database->create_table("score_log", " $database->create_table("score_log", "
id SCORE_AIPK, id SCORE_AIPK,
date_sent SCORE_DATETIME NOT NULL, date_sent TIMESTAMP NOT NULL,
section VARCHAR(32) NOT NULL, section VARCHAR(32) NOT NULL,
username VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL,
address SCORE_INET NOT NULL, address SCORE_INET NOT NULL,

View file

@ -15,7 +15,7 @@ class Notes extends Extension
image_id INTEGER NOT NULL, image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
user_ip CHAR(15) NOT NULL, user_ip CHAR(15) NOT NULL,
date SCORE_DATETIME NOT NULL, date TIMESTAMP NOT NULL,
x1 INTEGER NOT NULL, x1 INTEGER NOT NULL,
y1 INTEGER NOT NULL, y1 INTEGER NOT NULL,
height INTEGER NOT NULL, height INTEGER NOT NULL,
@ -30,7 +30,7 @@ class Notes extends Extension
id SCORE_AIPK, id SCORE_AIPK,
image_id INTEGER NOT NULL, image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
date SCORE_DATETIME NOT NULL, date TIMESTAMP NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
"); ");
@ -44,7 +44,7 @@ class Notes extends Extension
image_id INTEGER NOT NULL, image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
user_ip CHAR(15) NOT NULL, user_ip CHAR(15) NOT NULL,
date SCORE_DATETIME NOT NULL, date TIMESTAMP NOT NULL,
x1 INTEGER NOT NULL, x1 INTEGER NOT NULL,
y1 INTEGER NOT NULL, y1 INTEGER NOT NULL,
height INTEGER NOT NULL, height INTEGER NOT NULL,

View file

@ -59,7 +59,7 @@ class PrivMsg extends Extension
from_id INTEGER NOT NULL, from_id INTEGER NOT NULL,
from_ip SCORE_INET NOT NULL, from_ip SCORE_INET NOT NULL,
to_id INTEGER NOT NULL, to_id INTEGER NOT NULL,
sent_date SCORE_DATETIME NOT NULL, sent_date TIMESTAMP NOT NULL,
subject VARCHAR(64) NOT NULL, subject VARCHAR(64) NOT NULL,
message TEXT NOT NULL, message TEXT NOT NULL,
is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,

View file

@ -86,7 +86,7 @@ class Pools extends Extension
public SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, public SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
description TEXT, description TEXT,
date SCORE_DATETIME NOT NULL, date TIMESTAMP NOT NULL,
posts INTEGER NOT NULL DEFAULT 0, posts INTEGER NOT NULL DEFAULT 0,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
"); ");
@ -104,7 +104,7 @@ class Pools extends Extension
action INTEGER NOT NULL, action INTEGER NOT NULL,
images TEXT, images TEXT,
count INTEGER NOT NULL DEFAULT 0, count INTEGER NOT NULL DEFAULT 0,
date SCORE_DATETIME NOT NULL, date TIMESTAMP NOT NULL,
FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
"); ");

View file

@ -101,7 +101,7 @@ class SourceHistory extends Extension
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
user_ip SCORE_INET NOT NULL, user_ip SCORE_INET NOT NULL,
source TEXT NOT NULL, source TEXT NOT NULL,
date_set SCORE_DATETIME NOT NULL, date_set TIMESTAMP NOT NULL,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
"); ");

View file

@ -102,7 +102,7 @@ class TagHistory extends Extension
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
user_ip SCORE_INET NOT NULL, user_ip SCORE_INET NOT NULL,
tags TEXT NOT NULL, tags TEXT NOT NULL,
date_set SCORE_DATETIME NOT NULL, date_set TIMESTAMP NOT NULL,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
"); ");
@ -112,7 +112,7 @@ class TagHistory extends Extension
if ($config->get_int("ext_tag_history_version") == 1) { if ($config->get_int("ext_tag_history_version") == 1) {
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL"); $database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL");
$database->Execute($database->scoreql_to_sql("ALTER TABLE tag_histories ADD COLUMN date_set SCORE_DATETIME NOT NULL")); $database->Execute($database->scoreql_to_sql("ALTER TABLE tag_histories ADD COLUMN date_set TIMESTAMP NOT NULL"));
$config->set_int("ext_tag_history_version", 2); $config->set_int("ext_tag_history_version", 2);
} }

View file

@ -82,7 +82,7 @@ class Wiki extends Extension
id SCORE_AIPK, id SCORE_AIPK,
owner_id INTEGER NOT NULL, owner_id INTEGER NOT NULL,
owner_ip SCORE_INET NOT NULL, owner_ip SCORE_INET NOT NULL,
date SCORE_DATETIME DEFAULT NULL, date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
revision INTEGER NOT NULL DEFAULT 1, revision INTEGER NOT NULL DEFAULT 1,
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,