Adding a column as a foreign key gives ERROR column referenced in foreign key constraint does not exist
问题 I have the following set up, CREATE TABLE auth_user ( id int PRIMARY KEY ); CREATE TABLE links_chatpicmessage (); I'm trying to add a column named sender to links_chatpicmessage which is a foreign key to another table called auth_user 's id column. To achieve the above, I'm trying the following on terminal: ALTER TABLE links_chatpicmessage ADD FOREIGN KEY (sender) REFERENCES auth_user; But this gives me an error: ERROR: column "sender" referenced in foreign key constraint does not exist How