PostgreSQL does not support INDEX() inside the CREATE TABLE method. You must create the index as a separate query. Fortunately MySQL also support this way of doing things as well.

This commit is contained in:
jgen 2014-02-22 23:02:11 -05:00
parent 5effee4812
commit 9892d1f7fd
12 changed files with 21 additions and 27 deletions

View file

@ -62,9 +62,9 @@ class Artists extends Extension {
created DATETIME NOT NULL,
updated DATETIME NOT NULL,
notes TEXT,
INDEX(id),
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
");
$database->create_table("artist_members", "
id SCORE_AIPK,
artist_id INTEGER NOT NULL,
@ -72,7 +72,6 @@ class Artists extends Extension {
name VARCHAR(255) NOT NULL,
created DATETIME NOT NULL,
updated DATETIME NOT NULL,
INDEX (id),
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
");
@ -83,7 +82,6 @@ class Artists extends Extension {
created DATETIME,
updated DATETIME,
alias VARCHAR(255),
INDEX (id),
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
");
@ -94,7 +92,6 @@ class Artists extends Extension {
created DATETIME NOT NULL,
updated DATETIME NOT NULL,
url VARCHAR(1000) NOT NULL,
INDEX (id),
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
");

View file

@ -17,9 +17,9 @@ class Blocks extends Extension {
title VARCHAR(128) NOT NULL,
area VARCHAR(16) NOT NULL,
priority INTEGER NOT NULL,
content TEXT NOT NULL,
INDEX (pages)
content TEXT NOT NULL
");
$database->execute("CREATE INDEX blocks_pages_idx ON blocks(pages)", array());
$config->set_int("ext_blocks_version", 1);
}
}

View file

@ -42,9 +42,9 @@ class Bookmarks extends Extension {
owner_id INTEGER NOT NULL,
url TEXT NOT NULL,
title TEXT NOT NULL,
INDEX (owner_id),
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE
");
$database->execute("CREATE INDEX bookmark_owner_id_idx ON bookmark(owner_id)", array());
$config->set_int("ext_bookmarks_version", 1);
}
}

View file

@ -80,12 +80,12 @@ class CommentList extends Extension {
owner_ip SCORE_INET NOT NULL,
posted DATETIME DEFAULT NULL,
comment TEXT NOT NULL,
INDEX (image_id),
INDEX (owner_ip),
INDEX (posted),
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
");
$database->execute("CREATE INDEX comments_image_id_idx ON comments(image_id)", array());
$database->execute("CREATE INDEX comments_owner_id_idx ON comments(owner_id)", array());
$database->execute("CREATE INDEX comments_posted_idx ON bookmark(posted)", array());
$config->set_int("ext_comments_version", 3);
}
@ -97,9 +97,9 @@ class CommentList extends Extension {
owner_id INTEGER NOT NULL,
owner_ip CHAR(16) NOT NULL,
posted DATETIME DEFAULT NULL,
comment TEXT NOT NULL,
INDEX (image_id)
comment TEXT NOT NULL
");
$database->execute("CREATE INDEX comments_image_id_idx ON comments(image_id)", array());
$config->set_int("ext_comments_version", 1);
}

View file

@ -153,12 +153,12 @@ class Favorites extends Extension {
image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
created_at DATETIME NOT NULL,
INDEX(image_id),
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
)
");
$database->execute("CREATE INDEX user_favorites_image_id_idx ON user_favorites(image_id)", array());
$config->set_int("ext_favorites_version", 1);
}

View file

@ -29,20 +29,20 @@ class Forum extends Extension {
user_id INTEGER NOT NULL,
date DATETIME NOT NULL,
uptodate DATETIME NOT NULL,
INDEX (date),
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)", array());
$database->create_table("forum_posts", "
id SCORE_AIPK,
thread_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
date DATETIME NOT NULL,
message TEXT,
INDEX (date),
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
");
$database->execute("CREATE INDEX forum_posts_date_idx ON forum_posts(date)", array());
$config->set_int("forum_version", 2);
$config->set_int("forumTitleSubString", 25);

View file

@ -26,21 +26,21 @@ class Notes extends Extension {
height INTEGER NOT NULL,
width INTEGER NOT NULL,
note TEXT NOT NULL,
INDEX (image_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
");
$database->execute("CREATE INDEX notes_image_id_idx ON notes(image_id)", array());
$database->create_table("note_request", "
id SCORE_AIPK,
image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
date DATETIME NOT NULL,
INDEX (image_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
");
$database->execute("CREATE INDEX note_request_image_id_idx ON note_request(image_id)", array());
$database->create_table("note_histories", "
id SCORE_AIPK,
note_enable INTEGER NOT NULL,
@ -55,10 +55,10 @@ class Notes extends Extension {
height INTEGER NOT NULL,
width INTEGER NOT NULL,
note TEXT NOT NULL,
INDEX (image_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE
");
$database->execute("CREATE INDEX note_histories_image_id_idx ON note_histories(image_id)", array());
$config->set_int("notesNotesPerPage", 20);
$config->set_int("notesRequestsPerPage", 20);

View file

@ -268,10 +268,10 @@ class NumericScore extends Extension {
user_id INTEGER NOT NULL,
score INTEGER NOT NULL,
UNIQUE(image_id, user_id),
INDEX(image_id),
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
");
$database->execute("CREATE INDEX numeric_score_votes_image_id_idx ON numeric_score_votes(image_id)", array());
$config->set_int("ext_numeric_score_version", 1);
}
if($config->get_int("ext_numeric_score_version") < 2) {

View file

@ -35,7 +35,6 @@ class Pools extends Extension {
description TEXT,
date DATETIME NOT NULL,
posts INTEGER NOT NULL DEFAULT 0,
INDEX (id),
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
");
$database->create_table("pool_images", "
@ -53,7 +52,6 @@ class Pools extends Extension {
images TEXT,
count INTEGER NOT NULL DEFAULT 0,
date DATETIME NOT NULL,
INDEX (id),
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
");

View file

@ -94,10 +94,10 @@ class Source_History extends Extension {
user_ip SCORE_INET NOT NULL,
source TEXT NOT NULL,
date_set DATETIME NOT NULL,
INDEX(image_id),
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
");
$database->execute("CREATE INDEX source_histories_image_id_idx ON source_histories(image_id)", array());
$config->set_int("ext_source_history_version", 3);
}

View file

@ -94,10 +94,10 @@ class Tag_History extends Extension {
user_ip SCORE_INET NOT NULL,
tags TEXT NOT NULL,
date_set DATETIME NOT NULL,
INDEX(image_id),
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
");
$database->execute("CREATE INDEX tag_histories_image_id_idx ON tag_histories(image_id)", array());
$config->set_int("ext_tag_history_version", 3);
}

View file

@ -18,7 +18,6 @@ class Tips extends Extension {
enable SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
image TEXT NOT NULL,
text TEXT NOT NULL,
INDEX (id)
");
$database->execute("