-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_database.sql
More file actions
45 lines (39 loc) · 1.24 KB
/
Copy pathsetup_database.sql
File metadata and controls
45 lines (39 loc) · 1.24 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
39
40
41
42
43
44
45
-- Create the 'documents' table
CREATE TABLE IF NOT EXISTS documents (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
created_at TIMESTAMPTZ DEFAULT NOW(),
name TEXT NOT NULL,
file_path TEXT NOT NULL,
file_size BIGINT,
file_type TEXT,
share_link TEXT UNIQUE,
password TEXT,
expires_at TIMESTAMPTZ,
allow_download BOOLEAN DEFAULT TRUE,
custom_domain TEXT,
screenshot_protection BOOLEAN DEFAULT FALSE,
email_verification BOOLEAN DEFAULT FALSE,
apply_watermark BOOLEAN DEFAULT FALSE,
request_signature BOOLEAN DEFAULT FALSE,
allowed_email TEXT
);
-- Enable Row Level Security
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
-- SAFELY Create policies
-- Drop them first to avoid errors
DROP POLICY IF EXISTS "Public Read Access" ON documents;
CREATE POLICY "Public Read Access"
ON documents FOR SELECT
USING (true);
DROP POLICY IF EXISTS "Allow Anonymous Uploads" ON documents;
CREATE POLICY "Allow Anonymous Uploads"
ON documents FOR INSERT
WITH CHECK (true);
DROP POLICY IF EXISTS "Allow Updates" ON documents;
CREATE POLICY "Allow Updates"
ON documents FOR UPDATE
USING (true);
DROP POLICY IF EXISTS "Allow Deletes" ON documents;
CREATE POLICY "Allow Deletes"
ON documents FOR DELETE
USING (true);