From e72f9a6ef329822bc06b527322dfb91d5d50e864 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Wed, 3 Jun 2026 08:54:56 +0200 Subject: [PATCH] QoL fixes --- migrations/f0ckm_schema.sql | 8 ++++---- src/upload_handler.mjs | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/migrations/f0ckm_schema.sql b/migrations/f0ckm_schema.sql index af5b27a..2768e3a 100644 --- a/migrations/f0ckm_schema.sql +++ b/migrations/f0ckm_schema.sql @@ -593,7 +593,7 @@ CREATE TABLE public.comment_files ( id integer NOT NULL, comment_id integer, user_id integer NOT NULL, - dest character varying(40) NOT NULL, + dest character varying(60) NOT NULL, mime character varying(100) NOT NULL, size integer NOT NULL, checksum character varying(255) NOT NULL, @@ -887,7 +887,7 @@ ALTER SEQUENCE public.items_id_seq OWNER TO f0ckm; CREATE TABLE public.items ( id integer DEFAULT nextval('public.items_id_seq'::regclass) NOT NULL, src character varying(255) NOT NULL, - dest character varying(40) NOT NULL, + dest character varying(60) NOT NULL, mime character varying(100) NOT NULL, size integer NOT NULL, checksum character varying(255) NOT NULL, @@ -2857,8 +2857,8 @@ CREATE TABLE IF NOT EXISTS public.comment_polls ( CREATE TABLE IF NOT EXISTS public.comment_poll_options ( id SERIAL PRIMARY KEY, poll_id INTEGER NOT NULL REFERENCES public.comment_polls(id) ON DELETE CASCADE, - option_text TEXT NOT NULL, - display_order SMALLINT NOT NULL DEFAULT 0 + text TEXT NOT NULL, + sort_order SMALLINT NOT NULL DEFAULT 0 ); CREATE TABLE IF NOT EXISTS public.comment_poll_votes ( diff --git a/src/upload_handler.mjs b/src/upload_handler.mjs index 406cc45..055a7d9 100644 --- a/src/upload_handler.mjs +++ b/src/upload_handler.mjs @@ -26,6 +26,14 @@ db`ALTER TABLE items ADD COLUMN IF NOT EXISTS title text`.catch(() => {}); db`ALTER TABLE items ADD COLUMN IF NOT EXISTS width integer`.catch(() => {}); db`ALTER TABLE items ADD COLUMN IF NOT EXISTS height integer`.catch(() => {}); +// One-time migration: widen checksum column to varchar(255) for SHA-256 + bypass suffix support +// (old schema had varchar(40), sized for SHA-1 — SHA-256 is 64 chars and bypass suffix adds more) +db`ALTER TABLE items ALTER COLUMN checksum TYPE character varying(255)`.catch(() => {}); + +// One-time migration: widen dest column to varchar(60) — UUID (32) + dot + extension can exceed 40 chars +db`ALTER TABLE items ALTER COLUMN dest TYPE character varying(60)`.catch(() => {}); +db`ALTER TABLE comment_files ALTER COLUMN dest TYPE character varying(60)`.catch(() => {}); + export const handleUpload = async (req, res, self) => { // Manual session lookup is required here because this handler is called from a // bypass middleware that runs in parallel with the main session middleware.