-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
40 lines (38 loc) · 1.73 KB
/
Copy pathschema.sql
File metadata and controls
40 lines (38 loc) · 1.73 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
-- Tabla de pegas - pega.devschile.cl
CREATE TABLE IF NOT EXISTS pegas (
id SERIAL PRIMARY KEY,
url TEXT UNIQUE NOT NULL,
titulo TEXT NOT NULL,
empleador TEXT,
descripcion TEXT,
categoria TEXT,
ubicacion TEXT,
sueldo TEXT,
tags TEXT,
fecha_publicacion TIMESTAMP,
fuente TEXT NOT NULL DEFAULT 'linkedin',
email_origen TEXT,
activo BOOLEAN DEFAULT TRUE,
fecha_creacion TIMESTAMP DEFAULT NOW(),
fecha_actualizacion TIMESTAMP DEFAULT NOW(),
-- Si ya se incluyó en un resumen de Slack. DEFAULT FALSE para que toda
-- pega nueva salga en el próximo resumen automáticamente.
notificado_en_digest BOOLEAN NOT NULL DEFAULT FALSE
);
-- Índices para búsqueda
CREATE INDEX IF NOT EXISTS idx_pegas_fuente ON pegas(fuente);
CREATE INDEX IF NOT EXISTS idx_pegas_categoria ON pegas(categoria);
CREATE INDEX IF NOT EXISTS idx_pegas_fecha ON pegas(fecha_creacion DESC);
CREATE INDEX IF NOT EXISTS idx_pegas_activo ON pegas(activo);
CREATE INDEX IF NOT EXISTS idx_pegas_notificado ON pegas(notificado_en_digest) WHERE NOT notificado_en_digest;
-- Registra la última vez que cada disparador del pipeline (Gmail, GetOnBoard
-- + WorkingNomads, digest de Slack) efectivamente corrió, sin importar si
-- encontró datos nuevos o no. Vive en la base -- no en estado interno de
-- n8n -- porque ese estado se demostró frágil (se pierde con ediciones del
-- workflow) y porque un trigger puede dejar de dispararse en silencio sin
-- que nada lo note. Un chequeo periódico aparte compara ultima_corrida
-- contra el intervalo esperado de cada fuente y avisa si alguna se atrasó.
CREATE TABLE IF NOT EXISTS pipeline_heartbeat (
fuente TEXT PRIMARY KEY,
ultima_corrida TIMESTAMPTZ NOT NULL DEFAULT NOW()
);