Drop SCORE_DATETIME/NOW - all the databases we care about now support TIMESTAMP/CURRENT_TIMESTAMP
This commit is contained in:
parent
1210498e41
commit
6bc33ee691
16 changed files with 33 additions and 40 deletions
|
@ -279,7 +279,7 @@ EOD;
|
|||
id SCORE_AIPK,
|
||||
name VARCHAR(32) UNIQUE NOT NULL,
|
||||
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',
|
||||
email VARCHAR(128)
|
||||
");
|
||||
|
@ -296,7 +296,7 @@ EOD;
|
|||
source VARCHAR(255),
|
||||
width 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,
|
||||
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
|
||||
");
|
||||
|
|
|
@ -6,8 +6,6 @@ abstract class SCORE
|
|||
const BOOL_Y = "SCORE_BOOL_Y";
|
||||
const BOOL_N = "SCORE_BOOL_N";
|
||||
const BOOL = "SCORE_BOOL";
|
||||
const DATETIME = "SCORE_DATETIME";
|
||||
const NOW = "SCORE_NOW";
|
||||
const STRNORM = "SCORE_STRNORM";
|
||||
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_N, "'$this->BOOL_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::ILIKE, "LIKE", $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_N, $this->BOOL_N, $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::ILIKE, "ILIKE", $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_N, "'$this->BOOL_N'", $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::ILIKE, "LIKE", $data);
|
||||
return $data;
|
||||
|
|
|
@ -65,8 +65,8 @@ class Artists extends Extension
|
|||
id SCORE_AIPK,
|
||||
user_id INTEGER NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
created SCORE_DATETIME NOT NULL,
|
||||
updated SCORE_DATETIME NOT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL,
|
||||
notes TEXT,
|
||||
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,
|
||||
user_id INTEGER NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
created SCORE_DATETIME NOT NULL,
|
||||
updated SCORE_DATETIME NOT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL,
|
||||
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
|
||||
");
|
||||
|
@ -85,8 +85,8 @@ class Artists extends Extension
|
|||
id SCORE_AIPK,
|
||||
artist_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
created SCORE_DATETIME,
|
||||
updated SCORE_DATETIME,
|
||||
created TIMESTAMP,
|
||||
updated TIMESTAMP,
|
||||
alias VARCHAR(255),
|
||||
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
|
||||
|
@ -95,8 +95,8 @@ class Artists extends Extension
|
|||
id SCORE_AIPK,
|
||||
artist_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
created SCORE_DATETIME NOT NULL,
|
||||
updated SCORE_DATETIME NOT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL,
|
||||
url VARCHAR(1000) NOT NULL,
|
||||
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
|
||||
|
|
|
@ -26,7 +26,7 @@ class Blotter extends Extension
|
|||
global $database, $config;
|
||||
$database->create_table("blotter", "
|
||||
id SCORE_AIPK,
|
||||
entry_date SCORE_DATETIME DEFAULT SCORE_NOW,
|
||||
entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
entry_text TEXT NOT NULL,
|
||||
important SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N
|
||||
");
|
||||
|
|
|
@ -110,7 +110,7 @@ class CommentList extends Extension
|
|||
image_id INTEGER NOT NULL,
|
||||
owner_id INTEGER NOT NULL,
|
||||
owner_ip SCORE_INET NOT NULL,
|
||||
posted SCORE_DATETIME DEFAULT NULL,
|
||||
posted TIMESTAMP DEFAULT NULL,
|
||||
comment TEXT NOT NULL,
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
|
||||
|
@ -128,7 +128,7 @@ class CommentList extends Extension
|
|||
image_id INTEGER NOT NULL,
|
||||
owner_id INTEGER NOT NULL,
|
||||
owner_ip CHAR(16) NOT NULL,
|
||||
posted SCORE_DATETIME DEFAULT NULL,
|
||||
posted TIMESTAMP DEFAULT NULL,
|
||||
comment TEXT NOT NULL
|
||||
");
|
||||
$database->execute("CREATE INDEX comments_image_id_idx ON comments(image_id)", []);
|
||||
|
|
|
@ -208,7 +208,7 @@ class Favorites extends Extension
|
|||
$database->create_table("user_favorites", "
|
||||
image_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),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||
|
|
|
@ -21,8 +21,8 @@ class Forum extends Extension
|
|||
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date SCORE_DATETIME NOT NULL,
|
||||
uptodate SCORE_DATETIME NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
uptodate TIMESTAMP NOT NULL,
|
||||
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)", []);
|
||||
|
@ -31,7 +31,7 @@ class Forum extends Extension
|
|||
id SCORE_AIPK,
|
||||
thread_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date SCORE_DATETIME NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
message TEXT,
|
||||
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
|
||||
|
|
|
@ -31,7 +31,7 @@ class ImageBan extends Extension
|
|||
$database->create_table("image_bans", "
|
||||
id SCORE_AIPK,
|
||||
hash CHAR(32) NOT NULL,
|
||||
date SCORE_DATETIME DEFAULT SCORE_NOW,
|
||||
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
reason TEXT NOT NULL
|
||||
");
|
||||
$config->set_int("ext_imageban_version", 1);
|
||||
|
|
|
@ -138,7 +138,7 @@ class IPBan extends Extension
|
|||
ip SCORE_INET NOT NULL,
|
||||
end_timestamp INTEGER,
|
||||
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,
|
||||
");
|
||||
$database->execute("CREATE INDEX bans__end_timestamp ON bans(end_timestamp)");
|
||||
|
@ -151,8 +151,8 @@ class IPBan extends Extension
|
|||
$database->Execute("CREATE TABLE bans (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
ip char(15) default NULL,
|
||||
date SCORE_DATETIME default NULL,
|
||||
end SCORE_DATETIME default NULL,
|
||||
date TIMESTAMP default NULL,
|
||||
end TIMESTAMP default NULL,
|
||||
reason varchar(255) default NULL,
|
||||
PRIMARY KEY (id)
|
||||
)");
|
||||
|
@ -198,7 +198,7 @@ class IPBan extends Extension
|
|||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class LogDatabase extends Extension
|
|||
if ($config->get_int("ext_log_database_version") < 1) {
|
||||
$database->create_table("score_log", "
|
||||
id SCORE_AIPK,
|
||||
date_sent SCORE_DATETIME NOT NULL,
|
||||
date_sent TIMESTAMP NOT NULL,
|
||||
section VARCHAR(32) NOT NULL,
|
||||
username VARCHAR(32) NOT NULL,
|
||||
address SCORE_INET NOT NULL,
|
||||
|
|
|
@ -15,7 +15,7 @@ class Notes extends Extension
|
|||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip CHAR(15) NOT NULL,
|
||||
date SCORE_DATETIME NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
x1 INTEGER NOT NULL,
|
||||
y1 INTEGER NOT NULL,
|
||||
height INTEGER NOT NULL,
|
||||
|
@ -30,7 +30,7 @@ class Notes extends Extension
|
|||
id SCORE_AIPK,
|
||||
image_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 (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||
");
|
||||
|
@ -44,7 +44,7 @@ class Notes extends Extension
|
|||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip CHAR(15) NOT NULL,
|
||||
date SCORE_DATETIME NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
x1 INTEGER NOT NULL,
|
||||
y1 INTEGER NOT NULL,
|
||||
height INTEGER NOT NULL,
|
||||
|
|
|
@ -59,7 +59,7 @@ class PrivMsg extends Extension
|
|||
from_id INTEGER NOT NULL,
|
||||
from_ip SCORE_INET NOT NULL,
|
||||
to_id INTEGER NOT NULL,
|
||||
sent_date SCORE_DATETIME NOT NULL,
|
||||
sent_date TIMESTAMP NOT NULL,
|
||||
subject VARCHAR(64) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
|
|
|
@ -86,7 +86,7 @@ class Pools extends Extension
|
|||
public SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
date SCORE_DATETIME NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
posts INTEGER NOT NULL DEFAULT 0,
|
||||
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,
|
||||
images TEXT,
|
||||
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 (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
|
|
|
@ -101,7 +101,7 @@ class SourceHistory extends Extension
|
|||
user_id INTEGER NOT NULL,
|
||||
user_ip SCORE_INET 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 (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
");
|
||||
|
|
|
@ -102,7 +102,7 @@ class TagHistory extends Extension
|
|||
user_id INTEGER NOT NULL,
|
||||
user_ip SCORE_INET 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 (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) {
|
||||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class Wiki extends Extension
|
|||
id SCORE_AIPK,
|
||||
owner_id INTEGER NOT NULL,
|
||||
owner_ip SCORE_INET NOT NULL,
|
||||
date SCORE_DATETIME DEFAULT NULL,
|
||||
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
revision INTEGER NOT NULL DEFAULT 1,
|
||||
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
|
|
Reference in a new issue