forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
570 lines
15 KiB
570 lines
15 KiB
--
|
|
-- PostgreSQL database dump
|
|
--
|
|
|
|
SET client_encoding = 'LATIN1';
|
|
SET check_function_bodies = false;
|
|
SET client_min_messages = warning;
|
|
|
|
|
|
--
|
|
-- Name: actualizacao; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE actualizacao (
|
|
hora timestamp without time zone,
|
|
id serial NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.actualizacao OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: avisos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE avisos (
|
|
id integer NOT NULL,
|
|
tipo integer DEFAULT 0 NOT NULL,
|
|
empresa_id integer,
|
|
estabelecimento_id integer,
|
|
trabalhador_id integer,
|
|
evento_id integer,
|
|
data_aviso date NOT NULL,
|
|
data_evento date,
|
|
descricao character varying(255)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.avisos OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: contactos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE contactos (
|
|
id integer NOT NULL,
|
|
nome character varying(255),
|
|
telefone character varying(255),
|
|
telemovel character varying(255),
|
|
fax character varying(255),
|
|
email character varying(255),
|
|
cargo character varying(255)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.contactos OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: empresas; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE empresas (
|
|
id integer NOT NULL,
|
|
designacao_social character varying(255) DEFAULT ''::character varying NOT NULL,
|
|
servico_saude_tipo integer,
|
|
servico_saude_designacao character varying(255) DEFAULT 'Sociedade Ibu00e9rica de Prevenu00e7u00e3o de Riscos Profissionais'::character varying,
|
|
servico_higiene_tipo integer,
|
|
servico_higiene_designacao character varying(255),
|
|
inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
|
|
morada character varying(255),
|
|
codigo_postal character varying(8),
|
|
localidade character varying(255),
|
|
distrito character varying(255),
|
|
concelho character varying(255),
|
|
numero_trabalhadores integer,
|
|
data_proposta date,
|
|
data_aceitacao date,
|
|
perfil_1 character varying(255),
|
|
perfil_2 character varying(255),
|
|
data_envio_contrato date,
|
|
data_recepcao_contrato date,
|
|
data_envio_idict date,
|
|
cae character varying(255),
|
|
contribuinte character varying(255),
|
|
seguranca_social character varying(255),
|
|
codigo_1 character varying(255),
|
|
codigo_2 character varying(255),
|
|
codigo_3 character varying(255),
|
|
servicos integer,
|
|
contacto_1 integer,
|
|
contacto_2 integer,
|
|
data_relatorio_anual date,
|
|
preco_higiene double precision,
|
|
preco_medicina double precision,
|
|
periodicidade character varying(255),
|
|
actividade character varying(255),
|
|
actualizacao timestamp without time zone,
|
|
designacao_social_plain character varying(255)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.empresas OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: errors; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE errors (
|
|
id integer NOT NULL,
|
|
date timestamp without time zone,
|
|
"type" character varying(20),
|
|
environment character varying(255),
|
|
description character varying(65535)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.errors OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: estabelecimentos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE estabelecimentos (
|
|
id integer NOT NULL,
|
|
nome character varying(255) DEFAULT ''::character varying NOT NULL,
|
|
localidade character varying(255),
|
|
inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
|
|
empresa_id integer DEFAULT 0 NOT NULL,
|
|
morada character varying(255),
|
|
codigo_postal character varying(255),
|
|
contacto character varying(255),
|
|
historico character varying(65535),
|
|
actualizacao timestamp without time zone,
|
|
nome_plain character varying(255)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.estabelecimentos OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: exames; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE exames (
|
|
id integer NOT NULL,
|
|
data date,
|
|
tipo integer DEFAULT 0 NOT NULL,
|
|
ocasional integer,
|
|
outro_tipo character varying(255),
|
|
resultado integer,
|
|
outra_funcao_1 character varying(255),
|
|
outra_funcao_2 character varying(255),
|
|
outra_funcao_3 character varying(255),
|
|
outra_funcao_4 character varying(255),
|
|
proximo_exame date,
|
|
outras_recomendacoes character varying(65535),
|
|
inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
|
|
trabalhador_id integer DEFAULT 0 NOT NULL,
|
|
medico_id integer DEFAULT 0 NOT NULL,
|
|
pdf bytea
|
|
);
|
|
|
|
|
|
ALTER TABLE public.exames OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: exames_perfis; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE exames_perfis (
|
|
id integer NOT NULL,
|
|
perfil integer DEFAULT 0 NOT NULL,
|
|
tipo integer DEFAULT 0 NOT NULL,
|
|
multiplicador integer DEFAULT 0 NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.exames_perfis OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: historico_estabelecimento; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE historico_estabelecimento (
|
|
id integer NOT NULL,
|
|
estabelecimento_id integer DEFAULT 0 NOT NULL,
|
|
data date,
|
|
texto character varying(65535)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.historico_estabelecimento OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: ids; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE ids (
|
|
id integer NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.ids OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: marcacoes_empresa; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE marcacoes_empresa (
|
|
id integer NOT NULL,
|
|
data date NOT NULL,
|
|
texto character varying(65535),
|
|
empresa_id integer DEFAULT 0 NOT NULL,
|
|
realizada character(1)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.marcacoes_empresa OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: marcacoes_estabelecimento; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE marcacoes_estabelecimento (
|
|
id integer NOT NULL,
|
|
data date NOT NULL,
|
|
realizada character(1) DEFAULT 'n'::bpchar NOT NULL,
|
|
data_email date,
|
|
data_relatorio date,
|
|
estabelecimento_id integer DEFAULT 0 NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.marcacoes_estabelecimento OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: marcacoes_trabalhador; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE marcacoes_trabalhador (
|
|
id integer NOT NULL,
|
|
data date,
|
|
realizada character(1) DEFAULT 'n'::bpchar NOT NULL,
|
|
data_email date,
|
|
data_relatorio date,
|
|
tipo integer,
|
|
trabalhador_id integer
|
|
);
|
|
|
|
|
|
ALTER TABLE public.marcacoes_trabalhador OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: medicos; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE medicos (
|
|
id integer NOT NULL,
|
|
nome character varying(255) DEFAULT ''::character varying NOT NULL,
|
|
numero_cedula character varying(255) DEFAULT ''::character varying NOT NULL,
|
|
inactivo character(1) DEFAULT 'n'::bpchar NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.medicos OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: tipos_exames_comp; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE tipos_exames_comp (
|
|
id integer NOT NULL,
|
|
ordem integer DEFAULT 0 NOT NULL,
|
|
descricao character varying(255) DEFAULT ''::character varying NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.tipos_exames_comp OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: trabalhadores; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
CREATE TABLE trabalhadores (
|
|
id integer NOT NULL,
|
|
nome character varying(255) DEFAULT ''::character varying NOT NULL,
|
|
sexo character(1),
|
|
data_nascimento date,
|
|
nacionalidade character varying(255),
|
|
numero_mecanografico character varying(255),
|
|
data_admissao date,
|
|
categoria character varying(255),
|
|
local_trabalho character varying(255),
|
|
funcao_proposta character varying(255),
|
|
data_admissao_funcao date,
|
|
observacoes character varying(65535),
|
|
inactivo character(1) DEFAULT 'n'::bpchar NOT NULL,
|
|
estabelecimento_id integer DEFAULT 0 NOT NULL,
|
|
data_demissao date,
|
|
observacoes_gestao character varying(65535),
|
|
perfil integer,
|
|
actualizacao timestamp without time zone,
|
|
nome_plain character varying(255)
|
|
);
|
|
|
|
|
|
ALTER TABLE public.trabalhadores OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: actualizacao_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY actualizacao
|
|
ADD CONSTRAINT actualizacao_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.actualizacao_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: avisos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY avisos
|
|
ADD CONSTRAINT avisos_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.avisos_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: contactos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY contactos
|
|
ADD CONSTRAINT contactos_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.contactos_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: empresas_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY empresas
|
|
ADD CONSTRAINT empresas_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.empresas_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: errors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY errors
|
|
ADD CONSTRAINT errors_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.errors_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: estabelecimentos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY estabelecimentos
|
|
ADD CONSTRAINT estabelecimentos_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.estabelecimentos_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: exames_perfis_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY exames_perfis
|
|
ADD CONSTRAINT exames_perfis_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.exames_perfis_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: exames_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY exames
|
|
ADD CONSTRAINT exames_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.exames_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: historico_estabelecimento_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY historico_estabelecimento
|
|
ADD CONSTRAINT historico_estabelecimento_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.historico_estabelecimento_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: ids_pk; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY ids
|
|
ADD CONSTRAINT ids_pk PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.ids_pk OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: marcacoes_empresa_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY marcacoes_empresa
|
|
ADD CONSTRAINT marcacoes_empresa_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.marcacoes_empresa_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: marcacoes_estabelecimento_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY marcacoes_estabelecimento
|
|
ADD CONSTRAINT marcacoes_estabelecimento_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.marcacoes_estabelecimento_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: marcacoes_trabalhador_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY marcacoes_trabalhador
|
|
ADD CONSTRAINT marcacoes_trabalhador_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.marcacoes_trabalhador_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: medicos_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY medicos
|
|
ADD CONSTRAINT medicos_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.medicos_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: tipos_exames_comp_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY tipos_exames_comp
|
|
ADD CONSTRAINT tipos_exames_comp_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.tipos_exames_comp_pkey OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: trabalhadores_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
|
|
--
|
|
|
|
ALTER TABLE ONLY trabalhadores
|
|
ADD CONSTRAINT trabalhadores_pkey PRIMARY KEY (id);
|
|
|
|
|
|
ALTER INDEX public.trabalhadores_pkey OWNER TO postgres;
|
|
|
|
|
|
--
|
|
-- Name: avisos_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY avisos
|
|
ADD CONSTRAINT avisos_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id);
|
|
|
|
|
|
--
|
|
-- Name: avisos_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY avisos
|
|
ADD CONSTRAINT avisos_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
|
|
|
|
|
|
--
|
|
-- Name: empresas_contacto_1_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY empresas
|
|
ADD CONSTRAINT empresas_contacto_1_fkey FOREIGN KEY (contacto_1) REFERENCES contactos(id);
|
|
|
|
|
|
--
|
|
-- Name: empresas_contacto_2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY empresas
|
|
ADD CONSTRAINT empresas_contacto_2_fkey FOREIGN KEY (contacto_2) REFERENCES contactos(id);
|
|
|
|
|
|
--
|
|
-- Name: estabelecimentos_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY estabelecimentos
|
|
ADD CONSTRAINT estabelecimentos_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id);
|
|
|
|
|
|
--
|
|
-- Name: exames_medico_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY exames
|
|
ADD CONSTRAINT exames_medico_id_fkey FOREIGN KEY (medico_id) REFERENCES medicos(id);
|
|
|
|
|
|
--
|
|
-- Name: exames_perfis_tipo_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY exames_perfis
|
|
ADD CONSTRAINT exames_perfis_tipo_fkey FOREIGN KEY (tipo) REFERENCES tipos_exames_comp(id);
|
|
|
|
|
|
--
|
|
-- Name: historico_estabelecimento_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY historico_estabelecimento
|
|
ADD CONSTRAINT historico_estabelecimento_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
|
|
|
|
|
|
--
|
|
-- Name: marcacoes_empresa_empresa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY marcacoes_empresa
|
|
ADD CONSTRAINT marcacoes_empresa_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas(id);
|
|
|
|
|
|
--
|
|
-- Name: marcacoes_estabelecimento_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY marcacoes_estabelecimento
|
|
ADD CONSTRAINT marcacoes_estabelecimento_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
|
|
|
|
|
|
--
|
|
-- Name: trabalhadores_estabelecimento_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY trabalhadores
|
|
ADD CONSTRAINT trabalhadores_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos(id);
|
|
|
|
|
|
|
|
--
|
|
-- Name: public; Type: ACL; Schema: -; Owner: postgres
|
|
--
|
|
|
|
REVOKE ALL ON SCHEMA public FROM PUBLIC;
|
|
REVOKE ALL ON SCHEMA public FROM postgres;
|
|
GRANT ALL ON SCHEMA public TO postgres;
|
|
GRANT ALL ON SCHEMA public TO PUBLIC;
|
|
|
|
|
|
|