serve project files by token hash, preview images inline and download other files

This commit is contained in:
dev
2026-09-06 11:33:33 +03:00
parent c5fdf006f5
commit ac8621c5aa
5 changed files with 45 additions and 13 deletions
+14 -1
View File
@@ -30,4 +30,17 @@ BEGIN
INSERT INTO students (name)
SELECT DISTINCT student_name FROM entries WHERE student_name IS NOT NULL AND student_name <> ''
ON CONFLICT (name) DO NOTHING;
END $$;
END $$;
CREATE TABLE IF NOT EXISTS project_files (
id SERIAL PRIMARY KEY,
entry_id INT NOT NULL REFERENCES entries(id) ON DELETE CASCADE,
token VARCHAR(64),
path VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
created_at TIMESTAMPTZ DEFAULT now()
);
UPDATE project_files SET token = md5(random()::text || clock_timestamp()::text) WHERE token IS NULL;
ALTER TABLE project_files ALTER COLUMN token SET NOT NULL;
CREATE UNIQUE INDEX IF NOT EXISTS project_files_token_key ON project_files(token);