-- Table: ecd_oficial -- DROP TABLE ecd_oficial; CREATE TABLE ecd_oficial ( id serial NOT NULL, descricao varchar(255), descricao_plain varchar(255), ordem int4, activo char(1), CONSTRAINT ecd_oficial_pkey PRIMARY KEY (id) ) WITHOUT OIDS; ALTER TABLE ecd_oficial OWNER TO postgres; -- Table: prestadores -- DROP TABLE prestadores; CREATE TABLE prestadores ( id serial NOT NULL, nome varchar(255), nome_plain varchar(255), morada varchar(2048), codigo_postal varchar(16), localidade varchar(255), localidade_cp varchar(255), contacto_id int4, activo char(1), faz_consultas char(1), faz_ecds char(1), CONSTRAINT prestadores_pkey PRIMARY KEY (id), CONSTRAINT prestadores_contacto_id_fkey FOREIGN KEY (contacto_id) REFERENCES contactos (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) WITHOUT OIDS; ALTER TABLE prestadores OWNER TO postgres; -- Table: prestadores_grupos_protocolo -- DROP TABLE prestadores_grupos_protocolo; CREATE TABLE prestadores_grupos_protocolo ( id serial NOT NULL, prestador_id int4 NOT NULL, grupo_protocolo_id int4 NOT NULL, CONSTRAINT prestadores_grupos_protocolo_pkey PRIMARY KEY (id), CONSTRAINT prestadores_grupos_protocolo_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) REFERENCES prt_grupos_protocolo (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT prestadores_grupos_protocolo_prestador_id_fkey FOREIGN KEY (prestador_id) REFERENCES prestadores (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) WITHOUT OIDS; ALTER TABLE prestadores_grupos_protocolo OWNER TO postgres; -- Table: marcacoes_trabalhador_estados -- DROP TABLE marcacoes_trabalhador_estados; CREATE TABLE marcacoes_trabalhador_estados ( id serial NOT NULL, data date, estado int4, marcacao_id int4, CONSTRAINT marcacoes_trabalhador_estados_pkey PRIMARY KEY (id), CONSTRAINT marcacoes_trabalhador_estados_marcacao_id_fkey FOREIGN KEY (marcacao_id) REFERENCES marcacoes_trabalhador (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) WITHOUT OIDS; ALTER TABLE marcacoes_trabalhador_estados OWNER TO postgres; alter table marcacoes_grupos_realizados add marcacoes_trabalhador_estado_id int4 references marcacoes_trabalhador_estados(id); -- Table: lembretes_tipos -- DROP TABLE lembretes_tipos; CREATE TABLE lembretes_tipos ( id serial NOT NULL, codigo varchar(16) NOT NULL, descricao varchar(255) NOT NULL, ordem int4 NOT NULL, activo char(1) NOT NULL DEFAULT 'y'::bpchar, CONSTRAINT lembretes_tipos_pkey PRIMARY KEY (id) ) WITHOUT OIDS; ALTER TABLE lembretes_tipos OWNER TO postgres; INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) VALUES( 'EXTERNO','Avisos Externos', 1, 'y' ); INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) VALUES( 'REMARCACOES', 'Remarca\\u00e7\\u00f5es', 3 , 'y' ); INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) VALUES( 'MARCACOES', 'Marca\\u00e7\\u00f5es Pendentes', 2, 'y' ); INSERT INTO lembretes_tipos (codigo, descricao, ordem, activo ) VALUES( 'OUTROS','Outros',4,'y' ); -- Table: lembretes -- DROP TABLE lembretes; CREATE TABLE lembretes ( id serial NOT NULL, tipo_id int4 NOT NULL, data date NOT NULL, descricao varchar(255) NOT NULL, texto varchar(16384), empresa_id int4, estabelecimento_id int4, trabalhador_id int4, marcacao_estabelecimento_id int4, marcacao_trabalhador_id int4, enviar_email char(1) DEFAULT 'n'::bpchar, periodicidade_dias int4, periodicidade_meses int4, ultimo_envio date, CONSTRAINT lembretes_pkey PRIMARY KEY (id), CONSTRAINT lembretes_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT lembretes_estabelecimento_id_fkey FOREIGN KEY (estabelecimento_id) REFERENCES estabelecimentos (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT lembretes_marcacao_estabelecimento_id_fkey FOREIGN KEY (marcacao_estabelecimento_id) REFERENCES marcacoes_estabelecimento (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT lembretes_marcacao_trabalhador_id_fkey FOREIGN KEY (marcacao_trabalhador_id) REFERENCES marcacoes_trabalhador (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT lembretes_tipo_id_fkey FOREIGN KEY (tipo_id) REFERENCES lembretes_tipos (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT lembretes_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) REFERENCES trabalhadores (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) WITHOUT OIDS; ALTER TABLE lembretes OWNER TO postgres;