-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_schema.sql
More file actions
38 lines (36 loc) · 1.42 KB
/
db_schema.sql
File metadata and controls
38 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-- Create "uploads" table
CREATE TABLE IF NOT EXISTS uploads (
"index" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
-- epoch time when the file was uploaded
upload_epoch INTEGER NOT NULL,
-- original filename of the uploaded file
original_filename TEXT NOT NULL,
-- tagged filename (max 10 alphanumeric characters)
tagged_filename TEXT CHECK(LENGTH(tagged_filename) <= 10 AND tagged_filename GLOB '[0-9A-Za-z]*') NOT NULL,
-- file TTL in seconds
ttl INTEGER UNSIGNED NOT NULL,
-- indicate if the download is one-off
oneoff BOOLEAN NOT NULL,
-- SHA256 checksum of the download secret
download_secret TEXT CHECK(LENGTH(download_secret) = 64),
-- Epoch time when the file should be deleted
deletion_epoch INTEGER UNSIGNED,
-- Size of the uploaded file in bytes
file_size INTEGER UNSIGNED NOT NULL,
-- SHA1 checksum of the uploaded file
file_checksum TEXT CHECK(LENGTH(file_checksum) = 40) NOT NULL,
-- indicate if the file has been deleted
deleted BOOLEAN NOT NULL DEFAULT 0
);
-- Create "log" table
CREATE TABLE IF NOT EXISTS log (
"index" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
-- epoch time of the event
epoch INTEGER NOT NULL,
-- type of the event
event_type TEXT NOT NULL,
-- log message
message TEXT
);
-- Create index on "tagged_filename" for faster lookups
CREATE INDEX IF NOT EXISTS idx_tagged_filename ON uploads(tagged_filename);