I have a table named 'country'. with an identity column called 'id'
ALTER TABLE IF EXISTS public.country
ADD COLUMN "id " integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 );
I also have a table named 'county' in which I have a reference to the id of the previous table 'country_id'
When I am trying to set cascade actions
ALTER TABLE county
DROP CONSTRAINT country_id,
ADD CONSTRAINT country_id
FOREIGN KEY (country_id)
REFERENCES country (id)
ON UPDATE CASCADE ON DELETE SET NULL;
I get back 'column "id" referenced in foreign key constraint does not exist SQL state: 42703'
What am I doing wrong? Thanks a lot!
I have tried the same code for other tables and it worked.