Código SQL:
Ver originalCREATE TABLE commons.servicio (
id BIGINT NOT NULL,
version INTEGER NOT NULL,
codigo CHARACTER VARYING(15),
codigo_secuencia BIGINT,
razon_social CHARACTER VARYING(50),
cif CHARACTER VARYING(12),
sector CHARACTER VARYING(255),
calle CHARACTER VARYING(80),
numero CHARACTER VARYING(10),
piso CHARACTER VARYING(10),
poblacion CHARACTER VARYING(50),
provincia CHARACTER VARYING(255),
cp CHARACTER VARYING(5),
latitude NUMERIC(9,6),
longitude NUMERIC(9,6),
nombre_contacto CHARACTER VARYING(50),
apellido1 CHARACTER VARYING(50),
apellido2 CHARACTER VARYING(50),
telefono1 CHARACTER VARYING(15),
telefono2 CHARACTER VARYING(15),
email CHARACTER VARYING(50),
fax CHARACTER VARYING(15),
web CHARACTER VARYING(50),
security_domain_id BIGINT,
deleted TIMESTAMP WITH TIME zone
);
CREATE SEQUENCE commons.servicio_sequence
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE rrhh.proyecto ADD COLUMN servicio BIGINT;
ALTER TABLE ONLY rrhh.proyecto
ADD CONSTRAINT fk_proyecto_servicio FOREIGN KEY (servicio) REFERENCES commons.servicio(id);
Me da el siguiente error:
ERROR: there is no unique constraint matching given keys for referenced table "servicio"
********** Error **********
ERROR: there is no unique constraint matching given keys for referenced table "servicio"
SQL state: 42830
Y es una tabla recien creada.
Alguien me puede ayudar con lo que esta pasando.