From f03d11aafb7c0ee0f34b96f8339f46b5c1765cdc Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Mon, 15 Jan 2024 21:00:30 -0500 Subject: [PATCH] Label attachment field as sha256 instead of md5 for futureproofing --- sql/initialize.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/initialize.sql b/sql/initialize.sql index dc25f56..c5d7dc4 100644 --- a/sql/initialize.sql +++ b/sql/initialize.sql @@ -103,7 +103,7 @@ CREATE TABLE IF NOT EXISTS attachments ( attachment_id bigserial primary key , mimetype text NOT NULL , creation_time timestamp with time zone NOT NULL - , md5_hash text NOT NULL + , sha256_hash text NOT NULL , phash bigint , illegal boolean NOT NULL DEFAULT false , post_id bigint NOT NULL @@ -117,7 +117,9 @@ CREATE TABLE IF NOT EXISTS attachments ); CREATE INDEX attachments_creation_time_idx ON attachments (creation_time); CREATE INDEX attachments_post_id_idx ON attachments (post_id); -CREATE INDEX attachments_md5_hash_idx ON attachments (md5_hash); +CREATE INDEX attachments_sha256_hash_idx ON attachments (sha256_hash); +-- +-- Index using the bktree extension for quickly getting the closest phashes CREATE INDEX attachments_phash_bktree_index ON attachments USING spgist (phash bktree_ops);