diff --git a/core/_install.php b/core/_install.php index 3f799d46..d4a623d4 100644 --- a/core/_install.php +++ b/core/_install.php @@ -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 "); diff --git a/core/dbengine.php b/core/dbengine.php index 86b1a9d6..d0a9e6cd 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -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; diff --git a/ext/artists/main.php b/ext/artists/main.php index c4ea855b..8e22c67f 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -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 diff --git a/ext/blotter/main.php b/ext/blotter/main.php index ebc440c1..b1d90edc 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -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 "); diff --git a/ext/comment/main.php b/ext/comment/main.php index e4f5365e..c0eac631 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -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)", []); diff --git a/ext/favorites/main.php b/ext/favorites/main.php index 0b8b5b97..b6ea338b 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -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 diff --git a/ext/forum/main.php b/ext/forum/main.php index 06dfb7d0..d26bdd25 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -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 diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index e44882ae..01242973 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -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); diff --git a/ext/ipban/main.php b/ext/ipban/main.php index 8837f46b..098303c2 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -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); } } diff --git a/ext/log_db/main.php b/ext/log_db/main.php index 4e5e39d4..2c33c8d7 100644 --- a/ext/log_db/main.php +++ b/ext/log_db/main.php @@ -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, diff --git a/ext/notes/main.php b/ext/notes/main.php index a4a0c42b..cb14c280 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -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, diff --git a/ext/pm/main.php b/ext/pm/main.php index b0f53b19..7b842aef 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -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, diff --git a/ext/pools/main.php b/ext/pools/main.php index b96be493..09eb95ce 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -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 "); diff --git a/ext/source_history/main.php b/ext/source_history/main.php index 027522b5..701fb91b 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -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 "); diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index 51c70af5..0bf40949 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -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); } diff --git a/ext/wiki/main.php b/ext/wiki/main.php index e9c490de..70a6e5bf 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -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,