-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
24 lines (21 loc) · 921 Bytes
/
init.sql
File metadata and controls
24 lines (21 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- D-RAP Production Persistence Schema
-- Table to store active tunnel assignments
CREATE TABLE IF NOT EXISTS tunnels (
subdomain VARCHAR(64) PRIMARY KEY,
owner_id VARCHAR(64),
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
last_active TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
-- Table to store captured HTTP request history
CREATE TABLE IF NOT EXISTS request_history (
id UUID PRIMARY KEY,
tunnel_id VARCHAR(64) REFERENCES tunnels(subdomain) ON DELETE CASCADE,
timestamp TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
method VARCHAR(16) NOT NULL,
path TEXT NOT NULL,
host TEXT NOT NULL,
headers JSONB NOT NULL
);
-- Index for fast history lookups per tunnel
CREATE INDEX IF NOT EXISTS idx_request_history_tunnel_id ON request_history(tunnel_id);
CREATE INDEX IF NOT EXISTS idx_request_history_timestamp ON request_history(timestamp DESC);