aboutsummaryrefslogtreecommitdiff
path: root/initialize.sql
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-12-09 01:32:32 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-12-09 01:57:20 +0100
commit5c6a5b3ec2e820ec75c51ff025624520f714bb1e (patch)
tree69bd2f9490b9d77860ac22142f3e97a9792f3566 /initialize.sql
parent3c299f237d96a4fd3154fb4893525622c6bb673a (diff)
downloadgallery-5c6a5b3ec2e820ec75c51ff025624520f714bb1e.tar.gz
gallery-5c6a5b3ec2e820ec75c51ff025624520f714bb1e.tar.xz
gallery-5c6a5b3ec2e820ec75c51ff025624520f714bb1e.zip
Add a test
Diffstat (limited to 'initialize.sql')
-rw-r--r--initialize.sql12
1 files changed, 7 insertions, 5 deletions
diff --git a/initialize.sql b/initialize.sql
index 746b0e2..6d5a9ad 100644
--- a/initialize.sql
+++ b/initialize.sql
@@ -5,18 +5,19 @@ CREATE TABLE IF NOT EXISTS entry(
mtime INTEGER NOT NULL, -- Unix time of last modification in seconds
sha1 TEXT NOT NULL, -- SHA-1 hash of file in lowercase hexadecimal
PRIMARY KEY (path, basename)
-);
+) STRICT;
CREATE INDEX IF NOT EXISTS entry_sha1 ON entry(sha1, path, basename);
-- XXX: Shouldn't perhaps "entry.sha1" reference "image.sha1"?
+-- FIXME
CREATE TABLE IF NOT EXISTS image(
- sha1 TEXT NOT NULL REFERENCES entry(sha1),
+ sha1 TEXT NOT NULL REFERENCES entry(sha1, path, basename),
thumbw INTEGER, -- cached thumbnail width, if known
thumbh INTEGER, -- cached thumbnail height, if known
dhash INTEGER, -- uint64 perceptual hash as a signed integer
PRIMARY KEY (sha1)
-);
+) STRICT;
CREATE INDEX IF NOT EXISTS image_dhash ON image(dhash, sha1);
@@ -24,13 +25,14 @@ CREATE TABLE IF NOT EXISTS image_tag(
sha1 TEXT NOT NULL REFERENCES image(sha1),
tag TEXT NOT NULL,
PRIMARY KEY (sha1)
-);
+) STRICT;
+-- XXX: Perhaps this should be more like namespaces.
CREATE TABLE IF NOT EXISTS image_autotag(
sha1 TEXT NOT NULL REFERENCES image(sha1),
tag TEXT NOT NULL,
weight REAL NOT NULL, -- 0..1 normalized weight assigned to tag
PRIMARY KEY (sha1, tag)
-);
+) STRICT;
CREATE INDEX IF NOT EXISTS image_autotag_tag ON image_autotag(tag, sha1);