-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
72 lines (52 loc) · 1.97 KB
/
Copy pathschema.sql
File metadata and controls
72 lines (52 loc) · 1.97 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
CREATE TABLE IF NOT EXISTS opportunities (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
organization TEXT NOT NULL,
description TEXT,
location TEXT,
source TEXT,
source_url TEXT UNIQUE,
posted_date TIMESTAMP,
created_at TIMESTAMP DEFAULT NOW()
);
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS external_id TEXT;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS summary TEXT;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS skills JSONB NOT NULL DEFAULT '[]'::jsonb;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS category TEXT;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS work_mode TEXT NOT NULL DEFAULT 'Unspecified';
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS eligibility TEXT;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS deadline DATE;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS processing_status TEXT NOT NULL DEFAULT 'pending';
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS processing_error TEXT;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS processed_at TIMESTAMPTZ;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS prompt_version TEXT;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS raw_payload JSONB NOT NULL DEFAULT '{}'::jsonb;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS is_saved BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE opportunities
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW();
CREATE UNIQUE INDEX IF NOT EXISTS idx_opportunities_source_external_id
ON opportunities(source, external_id)
WHERE external_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_opportunities_category
ON opportunities(category);
CREATE INDEX IF NOT EXISTS idx_opportunities_work_mode
ON opportunities(work_mode);
CREATE INDEX IF NOT EXISTS idx_opportunities_saved
ON opportunities(is_saved);
CREATE INDEX IF NOT EXISTS idx_opportunities_skills
ON opportunities USING GIN(skills);
CREATE INDEX IF NOT EXISTS idx_opportunities_processing_status
ON opportunities(processing_status);