Reputation: 41
ALTER TABLE <table name> WITH NOCHECK
ADD CONSTRAINT attachments_user_id_fkey FOREIGN KEY (user_id)
REFERENCES public.users (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
The above query is throwing the following error ERROR: syntax error at or near "WITH NOCHECK"
Upvotes: 3
Views: 5274
Reputation: 434935
That appears to be SQL Server syntax. PostgreSQL doesn't support that WITH NOCHECK
, I think you want:
ALTER TABLE <table name>
ADD CONSTRAINT attachments_user_id_fkey FOREIGN KEY (user_id)
REFERENCES public.users (id) NOT VALID
You'll have to check the documentation to see if there are equivalents for the rest of the options you're trying to use.
Upvotes: 5