Mercurial > ~dholland > hg > swallowtail > index.cgi
changeset 42:e1017d556437
add unique indexes on number_in_pr
author | David A. Holland |
---|---|
date | Sun, 15 Jun 2014 18:16:12 -0400 |
parents | 81851564f552 |
children | debc55088b4f |
files | database/schema/messages.sql |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/database/schema/messages.sql Sun Jun 15 17:55:56 2014 -0400 +++ b/database/schema/messages.sql Sun Jun 15 18:16:12 2014 -0400 @@ -49,3 +49,12 @@ ) WITHOUT OIDS; +-- Create an index for number_in_pr both to enforce uniqueness and +-- to enable lookup. +CREATE UNIQUE INDEX ON messages (pr, number_in_pr); +-- XXX: does this work? +CREATE UNIQUE INDEX ON + SELECT messages.pr, attachments.number_in_pr + FROM messages, attachments + WHERE messages.id = attachments.msgid +;