From 992e0fd7ac2b0bd16dec0059531621ecaf63e17f Mon Sep 17 00:00:00 2001
From: Pinapelz <yukais@pinapelz.com>
Date: Sun, 11 Jan 2026 22:57:30 -0800
Subject: implement partial upload and re-assemble

---
 schema.sql | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

(limited to 'schema.sql')

diff --git a/schema.sql b/schema.sql
index aa5ee69..76bc07b 100644
--- a/schema.sql
+++ b/schema.sql
@@ -27,6 +27,28 @@ CREATE TABLE IF NOT EXISTS files (
         UNIQUE (directory_id, file_name)
 );
 
+-- =========================
+-- File partials table
+-- =========================
+CREATE TABLE IF NOT EXISTS file_partials (
+    partial_id BIGSERIAL PRIMARY KEY,
+    disc_channel_id VARCHAR(255) NOT NULL,
+    disc_message_id VARCHAR(255) NOT NULL,
+    directory_id BIGINT NOT NULL
+        REFERENCES directories(directory_id)
+        ON DELETE RESTRICT,
+    part_name TEXT NOT NULL,
+    part_number INTEGER NOT NULL,
+    part_size BIGINT NOT NULL,
+    original_filename TEXT NOT NULL,
+    file_description TEXT,
+    mime_type TEXT DEFAULT 'application/octet-stream',
+    uploaded_via_webhook BOOLEAN DEFAULT FALSE,
+    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+    CONSTRAINT partials_unique_name_per_directory
+        UNIQUE (directory_id, part_name)
+);
+
 -- =========================
 -- Indexes
 -- =========================
@@ -37,7 +59,13 @@ ON directories (path);
 CREATE INDEX IF NOT EXISTS idx_files_directory
 ON files (directory_id);
 
+CREATE INDEX IF NOT EXISTS idx_partials_directory
+ON file_partials (directory_id);
+
+CREATE INDEX IF NOT EXISTS idx_partials_original_filename
+ON file_partials (original_filename);
+
 
 INSERT INTO directories (path)
 VALUES ('')
-ON CONFLICT (path) DO NOTHING;
\ No newline at end of file
+ON CONFLICT (path) DO NOTHING;
-- 
cgit v1.2.3

