Mejoras: NER, embeddings, dashboard, docker-compose y limpieza
This commit is contained in:
parent
6c5aff9936
commit
d508dc2058
19 changed files with 2218 additions and 1185 deletions
38
migrations/002_unique_index_url_norm.sql
Normal file
38
migrations/002_unique_index_url_norm.sql
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
-- Añadir columna generada url_norm y crear índice único sobre ella.
|
||||
-- OJO: si ya existen duplicados, este índice fallará.
|
||||
-- Primero crea la columna si no existe:
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name='feeds' AND column_name='url_norm'
|
||||
) THEN
|
||||
ALTER TABLE feeds
|
||||
ADD COLUMN url_norm text GENERATED ALWAYS AS (normalize_url(url)) STORED;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- Índice único (concurrently para no bloquear). Requiere estar fuera de transacción.
|
||||
-- Si tu herramienta corre todo en una transacción, ejecuta estas dos líneas aparte.
|
||||
-- Quita duplicados antes si da error.
|
||||
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS feeds_url_norm_uniq ON feeds (url_norm)
|
||||
WHERE url_norm IS NOT NULL;
|
||||
|
||||
-- (Opcional) repetir lo mismo para fuentes_url y noticias si quieres esa garantía también:
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name='fuentes_url' AND column_name='url_norm'
|
||||
) THEN
|
||||
ALTER TABLE fuentes_url
|
||||
ADD COLUMN url_norm text GENERATED ALWAYS AS (normalize_url(url)) STORED;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS fuentes_url_norm_uniq ON fuentes_url (url_norm)
|
||||
WHERE url_norm IS NOT NULL;
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue