serve project files by token hash, preview images inline and download other files
This commit is contained in:
+14
-1
@@ -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);
|
||||
Reference in New Issue
Block a user