diff options
Diffstat (limited to 'util/sql/schema.sql')
-rw-r--r-- | util/sql/schema.sql | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/util/sql/schema.sql b/util/sql/schema.sql index 3fba4342..59240ea9 100644 --- a/util/sql/schema.sql +++ b/util/sql/schema.sql @@ -1,5 +1,3 @@ - - -- affiliate_links CREATE TABLE affiliate_links ( id SERIAL PRIMARY KEY, @@ -530,93 +528,3 @@ CREATE TABLE wlists ( added timestamptz NOT NULL DEFAULT NOW(), PRIMARY KEY(uid, vid) ); - - - -ALTER TABLE affiliate_links ADD FOREIGN KEY (rid) REFERENCES releases (id); -ALTER TABLE changes ADD FOREIGN KEY (requester) REFERENCES users (id) ON DELETE SET DEFAULT; -ALTER TABLE chars ADD FOREIGN KEY (latest) REFERENCES chars_rev (id) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE chars_rev ADD FOREIGN KEY (id) REFERENCES changes (id); -ALTER TABLE chars_rev ADD FOREIGN KEY (cid) REFERENCES chars (id); -ALTER TABLE chars_rev ADD FOREIGN KEY (main) REFERENCES chars (id); -ALTER TABLE chars_traits ADD FOREIGN KEY (cid) REFERENCES chars_rev (id); -ALTER TABLE chars_traits ADD FOREIGN KEY (tid) REFERENCES traits (id); -ALTER TABLE chars_vns ADD FOREIGN KEY (cid) REFERENCES chars_rev (id); -ALTER TABLE chars_vns ADD FOREIGN KEY (vid) REFERENCES vn (id); -ALTER TABLE chars_vns ADD FOREIGN KEY (rid) REFERENCES releases (id); -ALTER TABLE notifications ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE notifications ADD FOREIGN KEY (c_byuser) REFERENCES users (id) ON DELETE SET DEFAULT; -ALTER TABLE producers ADD FOREIGN KEY (latest) REFERENCES producers_rev (id) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE producers ADD FOREIGN KEY (rgraph) REFERENCES relgraphs (id); -ALTER TABLE producers_relations ADD FOREIGN KEY (pid1) REFERENCES producers_rev (id); -ALTER TABLE producers_relations ADD FOREIGN KEY (pid2) REFERENCES producers (id); -ALTER TABLE producers_rev ADD FOREIGN KEY (id) REFERENCES changes (id); -ALTER TABLE producers_rev ADD FOREIGN KEY (pid) REFERENCES producers (id); -ALTER TABLE quotes ADD FOREIGN KEY (vid) REFERENCES vn (id); -ALTER TABLE releases ADD FOREIGN KEY (latest) REFERENCES releases_rev (id) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE releases_lang ADD FOREIGN KEY (rid) REFERENCES releases_rev (id); -ALTER TABLE releases_media ADD FOREIGN KEY (rid) REFERENCES releases_rev (id); -ALTER TABLE releases_platforms ADD FOREIGN KEY (rid) REFERENCES releases_rev (id); -ALTER TABLE releases_producers ADD FOREIGN KEY (rid) REFERENCES releases_rev (id); -ALTER TABLE releases_producers ADD FOREIGN KEY (pid) REFERENCES producers (id); -ALTER TABLE releases_rev ADD FOREIGN KEY (id) REFERENCES changes (id); -ALTER TABLE releases_rev ADD FOREIGN KEY (rid) REFERENCES releases (id); -ALTER TABLE releases_vn ADD FOREIGN KEY (rid) REFERENCES releases_rev (id); -ALTER TABLE releases_vn ADD FOREIGN KEY (vid) REFERENCES vn (id); -ALTER TABLE rlists ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE rlists ADD FOREIGN KEY (rid) REFERENCES releases (id); -ALTER TABLE sessions ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE staff ADD FOREIGN KEY (latest) REFERENCES staff_rev (id) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE staff_alias ADD FOREIGN KEY (rid) REFERENCES staff_rev (id) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE staff_rev ADD FOREIGN KEY (id) REFERENCES changes (id); -ALTER TABLE staff_rev ADD FOREIGN KEY (sid) REFERENCES staff (id); -ALTER TABLE staff_rev ADD FOREIGN KEY (aid,id) REFERENCES staff_alias (id,rid); -ALTER TABLE tags ADD FOREIGN KEY (addedby) REFERENCES users (id) ON DELETE SET DEFAULT; -ALTER TABLE tags_aliases ADD FOREIGN KEY (tag) REFERENCES tags (id); -ALTER TABLE tags_parents ADD FOREIGN KEY (tag) REFERENCES tags (id); -ALTER TABLE tags_parents ADD FOREIGN KEY (parent) REFERENCES tags (id); -ALTER TABLE tags_vn ADD FOREIGN KEY (tag) REFERENCES tags (id); -ALTER TABLE tags_vn ADD FOREIGN KEY (vid) REFERENCES vn (id); -ALTER TABLE tags_vn ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE threads ADD FOREIGN KEY (id, count) REFERENCES threads_posts (tid, num) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE threads_posts ADD FOREIGN KEY (tid) REFERENCES threads (id); -ALTER TABLE threads_posts ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE SET DEFAULT; -ALTER TABLE threads_boards ADD FOREIGN KEY (tid) REFERENCES threads (id); -ALTER TABLE traits ADD FOREIGN KEY (addedby) REFERENCES users (id); -ALTER TABLE traits ADD FOREIGN KEY ("group") REFERENCES traits (id); -ALTER TABLE traits_parents ADD FOREIGN KEY (trait) REFERENCES traits (id); -ALTER TABLE traits_parents ADD FOREIGN KEY (parent) REFERENCES traits (id); -ALTER TABLE traits_chars ADD FOREIGN KEY (cid) REFERENCES chars (id); -ALTER TABLE traits_chars ADD FOREIGN KEY (tid) REFERENCES traits (id); -ALTER TABLE users_prefs ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE vn ADD FOREIGN KEY (latest) REFERENCES vn_rev (id) DEFERRABLE INITIALLY DEFERRED; -ALTER TABLE vn ADD FOREIGN KEY (rgraph) REFERENCES relgraphs (id); -ALTER TABLE vn_anime ADD FOREIGN KEY (aid) REFERENCES anime (id); -ALTER TABLE vn_anime ADD FOREIGN KEY (vid) REFERENCES vn_rev (id); -ALTER TABLE vn_relations ADD FOREIGN KEY (vid1) REFERENCES vn_rev (id); -ALTER TABLE vn_relations ADD FOREIGN KEY (vid2) REFERENCES vn (id); -ALTER TABLE vn_rev ADD FOREIGN KEY (id) REFERENCES changes (id); -ALTER TABLE vn_rev ADD FOREIGN KEY (vid) REFERENCES vn (id); -ALTER TABLE vn_screenshots ADD FOREIGN KEY (vid) REFERENCES vn_rev (id); -ALTER TABLE vn_screenshots ADD FOREIGN KEY (scr) REFERENCES screenshots (id); -ALTER TABLE vn_screenshots ADD FOREIGN KEY (rid) REFERENCES releases (id); -ALTER TABLE vn_seiyuu ADD FOREIGN KEY (cid) REFERENCES chars (id); -ALTER TABLE vn_seiyuu ADD FOREIGN KEY (vid) REFERENCES vn_rev (id); -ALTER TABLE vn_staff ADD FOREIGN KEY (vid) REFERENCES vn_rev (id); -ALTER TABLE vnlists ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE vnlists ADD FOREIGN KEY (vid) REFERENCES vn (id); -ALTER TABLE votes ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE votes ADD FOREIGN KEY (vid) REFERENCES vn (id); -ALTER TABLE wlists ADD FOREIGN KEY (uid) REFERENCES users (id) ON DELETE CASCADE; -ALTER TABLE wlists ADD FOREIGN KEY (vid) REFERENCES vn (id); - - -CREATE INDEX affiliate_links_rid ON affiliate_links (rid) WHERE NOT hidden; -CREATE INDEX releases_producers_rid ON releases_producers (rid); -CREATE INDEX releases_vn_vid ON releases_vn (vid); -CREATE INDEX tags_vn_date ON tags_vn (date); -CREATE INDEX tags_vn_vid ON tags_vn (vid); -CREATE INDEX vn_staff_vid ON vn_staff (vid); -CREATE INDEX vn_staff_aid ON vn_staff (aid); -CREATE UNIQUE INDEX chars_vns_pkey ON chars_vns (cid, vid, COALESCE(rid, 0)); - |