Unknown column in foreign key definition

I’m trying to add a new table to an already existing database but it keeps giving me an error “Unknown column ‘product_id’ in foreign key definition”.

CREATE TABLE product_review (
    prod_review_ref_no INTEGER PRIMARY KEY AUTOINCREMENT,
    review TEXT NOT NULL,
    comment TEXT NOT NULL,
    date TEXT NOT NULL,
    time TEXT NOT NULL,
    FOREIGN KEY (product_id) REFERENCES products(product_id)
);

Any help would be appreciated, kind regards

Answer

You must define your product_id column before setting the constraint.