X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=sql%2Fpr0n.sql;h=4729a37cdd9e9b71dbf2b922bd19fee46e66469e;hp=774c652bea1685d9d830c1bc9fd1e0b213a25ffd;hb=12e2d43c7d68a328e9c6e3ff2f3810d3b6799b47;hpb=78371bed0540017db52ae33e66fb7e9339f73301 diff --git a/sql/pr0n.sql b/sql/pr0n.sql index 774c652..4729a37 100644 --- a/sql/pr0n.sql +++ b/sql/pr0n.sql @@ -3,6 +3,7 @@ CREATE TABLE events ( "date" character varying NOT NULL, name character varying NOT NULL, vhost character varying NOT NULL, + hidden boolean NOT NULL DEFAULT false, PRIMARY KEY (vhost, event) ); @@ -33,8 +34,16 @@ CREATE TABLE images ( selected boolean DEFAULT false, model character varying, lens character varying, + is_render boolean NOT NULL DEFAULT false, -- Is this a render of another picture? (If so, don't show it separately.) + render_id integer, -- If not NULL, show this picture instead of ourselves for all JPEG-creation purposes. - FOREIGN KEY (vhost,event) REFERENCES events (vhost,event) + FOREIGN KEY (vhost,event) REFERENCES events (vhost,event), + FOREIGN KEY (vhost,event,render_id) REFERENCES images (vhost,event,id), + + -- Redundant with the primary key, but the foreign key needs it. + UNIQUE (vhost,event,id), + + CHECK (NOT (is_render AND (render_id IS NOT NULL))) ); CREATE UNIQUE INDEX unique_filenames ON images USING btree (vhost, event, filename); @@ -51,6 +60,8 @@ CREATE TABLE deleted_images ( selected boolean, model character varying, lens character varying + is_render boolean NOT NULL, + render_id integer, ); CREATE TABLE users ( @@ -66,11 +77,10 @@ CREATE TABLE exif_info ( key varchar NOT NULL, value varchar NOT NULL, - PRIMARY KEY ( image, key ) + PRIMARY KEY ( key, image ) ); -CREATE INDEX exif_info_key ON exif_info ( key ); -CLUSTER exif_info_key ON exif_info; +CLUSTER exif_info_pkey ON exif_info; GRANT INSERT ON TABLE deleted_images TO pr0n; GRANT INSERT,SELECT,UPDATE,DELETE ON TABLE events TO pr0n;