From 5cf94a887d8edbeb811ea440c6b8eef90e34f7a2 Mon Sep 17 00:00:00 2001
From: Bryan Newbold <bnewbold@archive.org>
Date: Mon, 26 Aug 2019 14:13:13 +0200
Subject: update shadow sandcrawler schema

---
 postgrest/sandcrawler_schema.sql | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'postgrest/sandcrawler_schema.sql')

diff --git a/postgrest/sandcrawler_schema.sql b/postgrest/sandcrawler_schema.sql
index 7460cdc..fd921ed 100644
--- a/postgrest/sandcrawler_schema.sql
+++ b/postgrest/sandcrawler_schema.sql
@@ -48,11 +48,12 @@ CREATE TABLE IF NOT EXISTS grobid (
 -- CREATE INDEX grobid_fatcat_release_idx ON grobid(fatcat_release);
 
 CREATE TABLE IF NOT EXISTS shadow (
-    sha1hex             TEXT NOT NULL CHECK (octet_length(sha1hex) = 40),
     shadow_corpus       TEXT NOT NULL CHECK (octet_length(shadow_corpus) >= 1),
-    shadow_id           TEXT CHECK (octet_length(shadow_id) >= 1),
+    shadow_id           TEXT NOT NULL CHECK (octet_length(shadow_id) >= 1),
+    sha1hex             TEXT NOT NULL CHECK (octet_length(sha1hex) = 40),
     doi                 TEXT CHECK (octet_length(doi) >= 1),
     pmid                TEXT CHECK (octet_length(pmid) >= 1),
     isbn13              TEXT CHECK (octet_length(isbn13) >= 1),
-    PRIMARY KEY(sha1hex, shadow_corpus)
+    PRIMARY KEY(shadow_corpus, shadow_id)
 );
+CREATE INDEX shadow_sha1hex_idx ON shadow(sha1hex);
-- 
cgit v1.2.3

