--
-- PostgreSQL database dump
--

-- Dumped from database version 16.9 (Ubuntu 16.9-0ubuntu0.24.04.1)
-- Dumped by pg_dump version 16.9 (Ubuntu 16.9-0ubuntu0.24.04.1)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: noticias_tsv_trigger(); Type: FUNCTION; Schema: public; Owner: rss
--

CREATE FUNCTION public.noticias_tsv_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$ begin new.tsv := setweight(to_tsvector('spanish', coalesce(new.titulo,'')), 'A') || setweight(to_tsvector('spanish', coalesce(new.resumen,'')), 'B'); return new; end $$;


ALTER FUNCTION public.noticias_tsv_trigger() OWNER TO rss;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: categorias; Type: TABLE; Schema: public; Owner: rss
--

CREATE TABLE public.categorias (
    id integer NOT NULL,
    nombre character varying(100) NOT NULL
);


ALTER TABLE public.categorias OWNER TO rss;

--
-- Name: categorias_id_seq; Type: SEQUENCE; Schema: public; Owner: rss
--

CREATE SEQUENCE public.categorias_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.categorias_id_seq OWNER TO rss;

--
-- Name: categorias_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rss
--

ALTER SEQUENCE public.categorias_id_seq OWNED BY public.categorias.id;


--
-- Name: continentes; Type: TABLE; Schema: public; Owner: rss
--

CREATE TABLE public.continentes (
    id integer NOT NULL,
    nombre character varying(50) NOT NULL
);


ALTER TABLE public.continentes OWNER TO rss;

--
-- Name: continentes_id_seq; Type: SEQUENCE; Schema: public; Owner: rss
--

CREATE SEQUENCE public.continentes_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.continentes_id_seq OWNER TO rss;

--
-- Name: continentes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rss
--

ALTER SEQUENCE public.continentes_id_seq OWNED BY public.continentes.id;


--
-- Name: feeds; Type: TABLE; Schema: public; Owner: rss
--

CREATE TABLE public.feeds (
    id integer NOT NULL,
    nombre character varying(255),
    descripcion text,
    url text NOT NULL,
    categoria_id integer,
    pais_id integer,
    idioma character(2),
    activo boolean DEFAULT true,
    fallos integer DEFAULT 0,
    last_etag character varying(255),
    last_modified character varying(255)
);


ALTER TABLE public.feeds OWNER TO rss;

--
-- Name: feeds_id_seq; Type: SEQUENCE; Schema: public; Owner: rss
--

CREATE SEQUENCE public.feeds_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.feeds_id_seq OWNER TO rss;

--
-- Name: feeds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rss
--

ALTER SEQUENCE public.feeds_id_seq OWNED BY public.feeds.id;


--
-- Name: noticias; Type: TABLE; Schema: public; Owner: rss
--

CREATE TABLE public.noticias (
    id character varying(32) NOT NULL,
    titulo text,
    resumen text,
    url text NOT NULL,
    fecha timestamp without time zone,
    imagen_url text,
    categoria_id integer,
    pais_id integer,
    tsv tsvector
);


ALTER TABLE public.noticias OWNER TO rss;

--
-- Name: paises; Type: TABLE; Schema: public; Owner: rss
--

CREATE TABLE public.paises (
    id integer NOT NULL,
    nombre character varying(100) NOT NULL,
    continente_id integer
);


ALTER TABLE public.paises OWNER TO rss;

--
-- Name: paises_id_seq; Type: SEQUENCE; Schema: public; Owner: rss
--

CREATE SEQUENCE public.paises_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.paises_id_seq OWNER TO rss;

--
-- Name: paises_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rss
--

ALTER SEQUENCE public.paises_id_seq OWNED BY public.paises.id;


--
-- Name: categorias id; Type: DEFAULT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.categorias ALTER COLUMN id SET DEFAULT nextval('public.categorias_id_seq'::regclass);


--
-- Name: continentes id; Type: DEFAULT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.continentes ALTER COLUMN id SET DEFAULT nextval('public.continentes_id_seq'::regclass);


--
-- Name: feeds id; Type: DEFAULT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.feeds ALTER COLUMN id SET DEFAULT nextval('public.feeds_id_seq'::regclass);


--
-- Name: paises id; Type: DEFAULT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.paises ALTER COLUMN id SET DEFAULT nextval('public.paises_id_seq'::regclass);


--
-- Name: categorias categorias_nombre_key; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.categorias
    ADD CONSTRAINT categorias_nombre_key UNIQUE (nombre);


--
-- Name: categorias categorias_pkey; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.categorias
    ADD CONSTRAINT categorias_pkey PRIMARY KEY (id);


--
-- Name: continentes continentes_nombre_key; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.continentes
    ADD CONSTRAINT continentes_nombre_key UNIQUE (nombre);


--
-- Name: continentes continentes_pkey; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.continentes
    ADD CONSTRAINT continentes_pkey PRIMARY KEY (id);


--
-- Name: feeds feeds_pkey; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_pkey PRIMARY KEY (id);


--
-- Name: feeds feeds_url_key; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_url_key UNIQUE (url);


--
-- Name: noticias noticias_pkey; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.noticias
    ADD CONSTRAINT noticias_pkey PRIMARY KEY (id);


--
-- Name: noticias noticias_url_key; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.noticias
    ADD CONSTRAINT noticias_url_key UNIQUE (url);


--
-- Name: paises paises_nombre_key; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.paises
    ADD CONSTRAINT paises_nombre_key UNIQUE (nombre);


--
-- Name: paises paises_pkey; Type: CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.paises
    ADD CONSTRAINT paises_pkey PRIMARY KEY (id);


--
-- Name: noticias_tsv_idx; Type: INDEX; Schema: public; Owner: rss
--

CREATE INDEX noticias_tsv_idx ON public.noticias USING gin (tsv);


--
-- Name: noticias tsvectorupdate; Type: TRIGGER; Schema: public; Owner: rss
--

CREATE TRIGGER tsvectorupdate BEFORE INSERT ON public.noticias FOR EACH ROW EXECUTE FUNCTION public.noticias_tsv_trigger();


--
-- Name: feeds feeds_categoria_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_categoria_id_fkey FOREIGN KEY (categoria_id) REFERENCES public.categorias(id) ON DELETE SET NULL;


--
-- Name: feeds feeds_pais_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_pais_id_fkey FOREIGN KEY (pais_id) REFERENCES public.paises(id) ON DELETE SET NULL;


--
-- Name: noticias noticias_categoria_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.noticias
    ADD CONSTRAINT noticias_categoria_id_fkey FOREIGN KEY (categoria_id) REFERENCES public.categorias(id) ON DELETE SET NULL;


--
-- Name: noticias noticias_pais_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.noticias
    ADD CONSTRAINT noticias_pais_id_fkey FOREIGN KEY (pais_id) REFERENCES public.paises(id) ON DELETE SET NULL;


--
-- Name: paises paises_continente_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: rss
--

ALTER TABLE ONLY public.paises
    ADD CONSTRAINT paises_continente_id_fkey FOREIGN KEY (continente_id) REFERENCES public.continentes(id) ON DELETE SET NULL;


--
-- PostgreSQL database dump complete
--

