preliminary image locking
This commit is contained in:
parent
c9283ef010
commit
830635c5a9
@ -54,6 +54,10 @@ class DBEngine {
|
||||
|
||||
public function init($db) {}
|
||||
|
||||
public function scoreql_to_sql($scoreql) {
|
||||
return $scoreql;
|
||||
}
|
||||
|
||||
public function create_table_sql($name, $data) {
|
||||
return "CREATE TABLE $name ($data)";
|
||||
}
|
||||
@ -65,7 +69,7 @@ class MySQL extends DBEngine {
|
||||
$db->Execute("SET NAMES utf8;");
|
||||
}
|
||||
|
||||
public function create_table_sql($name, $data) {
|
||||
public function scoreql_to_sql($data) {
|
||||
$data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY auto_increment", $data);
|
||||
$data = str_replace("SCORE_INET", "CHAR(15)", $data);
|
||||
$data = str_replace("SCORE_BOOL_Y", "'Y'", $data);
|
||||
@ -73,6 +77,11 @@ class MySQL extends DBEngine {
|
||||
$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);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function create_table_sql($name, $data) {
|
||||
$data = $this->scoreql_to_sql($data);
|
||||
$ctes = "TYPE=InnoDB DEFAULT CHARSET='utf8'";
|
||||
return "CREATE TABLE $name ($data) $ctes";
|
||||
}
|
||||
@ -80,7 +89,7 @@ class MySQL extends DBEngine {
|
||||
class PostgreSQL extends DBEngine {
|
||||
var $name = "pgsql";
|
||||
|
||||
public function create_table_sql($name, $data) {
|
||||
public function scoreql_to_sql($data) {
|
||||
$data = str_replace("SCORE_AIPK", "SERIAL PRIMARY KEY", $data);
|
||||
$data = str_replace("SCORE_INET", "INET", $data);
|
||||
$data = str_replace("SCORE_BOOL_Y", "'t'", $data);
|
||||
@ -88,6 +97,11 @@ class PostgreSQL extends DBEngine {
|
||||
$data = str_replace("SCORE_BOOL", "BOOL", $data);
|
||||
$data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data);
|
||||
$data = str_replace("SCORE_NOW", "current_time", $data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function create_table_sql($name, $data) {
|
||||
$data = $this->scoreql_to_sql($data);
|
||||
return "CREATE TABLE $name ($data)";
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,18 @@ class Upgrade implements Extension {
|
||||
}
|
||||
}
|
||||
$config->set_int("db_version", 7);
|
||||
log_info("Database at version 7");
|
||||
log_info("upgrade", "Database at version 7");
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// add column image->locked
|
||||
if($config->get_int("db_version") < 8) {
|
||||
$database->execute($database->engine->scoreql_to_sql(
|
||||
"ALTER TABLE images ADD COLUMN locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N"
|
||||
));
|
||||
$config->set_int("db_version", 8);
|
||||
log_info("upgrade", "Database at version 8");
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Upgrade(), 5);
|
||||
|
@ -233,7 +233,7 @@ function create_tables($dsn) { // {{{
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
||||
"));
|
||||
$db->execute("INSERT INTO config(name, value) VALUES('db_version', 7)");
|
||||
$db->execute("INSERT INTO config(name, value) VALUES('db_version', 8)");
|
||||
}
|
||||
$db->Close();
|
||||
} // }}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user