07-20-2023, 07:07 AM
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 do I fix this?
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 do I fix this?