--
--

\restrict LZ2nx9fMrCN178SHVBgyjcZqDHlHS6EXDgXq7k4AOUnFMqVRcKmkhNqX2aZUpQp


SET transaction_timeout = 0;
SELECT pg_catalog.set_config('search_path', '', false);

DROP TRIGGER IF EXISTS trg_new_registration ON public.registros_glicose;
ALTER TABLE IF EXISTS ONLY public.registros_glicose DROP CONSTRAINT IF EXISTS registros_glicose_pkey;
ALTER TABLE IF EXISTS public.registros_glicose ALTER COLUMN id DROP DEFAULT;
DROP SEQUENCE IF EXISTS public.registros_glicose_id_seq;
DROP FUNCTION IF EXISTS public.notify_new_record();
--
-- Name: notify_new_record(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.notify_new_record() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
PERFORM pg_notify('new_registration', row_to_json(NEW)::text);
RETURN NEW;
END;
$$;




--
-- Name: registros_glicose; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.registros_glicose (
    id integer NOT NULL,
    nivel integer NOT NULL,
    data date NOT NULL,
    horario time without time zone NOT NULL,
    periodo text NOT NULL,
    data_criacao timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);


--
-- Name: registros_glicose_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: registros_glicose_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.registros_glicose_id_seq OWNED BY public.registros_glicose.id;


--
-- Name: registros_glicose id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Data for Name: registros_glicose; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.registros_glicose (id, nivel, data, horario, periodo, data_criacao) FROM stdin;
\.


--
-- Name: registros_glicose_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.registros_glicose_id_seq', 65, true);


--
-- Name: registros_glicose registros_glicose_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.registros_glicose
    ADD CONSTRAINT registros_glicose_pkey PRIMARY KEY (id);


--
-- Name: registros_glicose trg_new_registration; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER trg_new_registration AFTER INSERT ON public.registros_glicose FOR EACH ROW EXECUTE FUNCTION public.notify_new_record();


--
--

\unrestrict LZ2nx9fMrCN178SHVBgyjcZqDHlHS6EXDgXq7k4AOUnFMqVRcKmkhNqX2aZUpQp

