-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.sql
More file actions
45 lines (41 loc) · 1.64 KB
/
seed.sql
File metadata and controls
45 lines (41 loc) · 1.64 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 collections table for organizing requests
CREATE TABLE IF NOT EXISTS collections (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create requests table for storing API requests
CREATE TABLE IF NOT EXISTS requests (
id SERIAL PRIMARY KEY,
collection_id INTEGER REFERENCES collections(id) ON DELETE CASCADE,
name VARCHAR(255) NOT NULL,
method VARCHAR(10) NOT NULL DEFAULT 'GET',
url TEXT NOT NULL,
headers JSONB DEFAULT '{}',
body TEXT,
body_type VARCHAR(50) DEFAULT 'none',
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create request_history table for storing request/response history
CREATE TABLE IF NOT EXISTS request_history (
id SERIAL PRIMARY KEY,
request_id INTEGER REFERENCES requests(id) ON DELETE CASCADE,
method VARCHAR(10) NOT NULL,
url TEXT NOT NULL,
headers JSONB DEFAULT '{}',
body TEXT,
response_status INTEGER,
response_headers JSONB DEFAULT '{}',
response_body TEXT,
response_time_ms INTEGER,
executed_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create indexes for better query performance
CREATE INDEX IF NOT EXISTS idx_requests_collection_id ON requests(collection_id);
CREATE INDEX IF NOT EXISTS idx_request_history_request_id ON request_history(request_id);
CREATE INDEX IF NOT EXISTS idx_request_history_executed_at ON request_history(executed_at DESC);
-- Insert a default collection
INSERT INTO collections (name, description) VALUES ('My Collection', 'Default collection for API requests');