I'm trying to install this 4chan clone: https://github.com/Ro0ul/4Chan-Clone I'm executing one of the queries on the sql folder on phpmyadmin:
CREATE TABLE comment(
id INT AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
body TEXT NOT NULL,
post_id INT NOT NULL,
posted_at DATETIME NOT NULL,
image_src VARCHAR(255),
board VARCHAR(50) NOT NULL,
FOREIGN KEY(post_id)
REFERENCES post(id)
ON DELETE CASCADE
)
But I get the error: #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
How can I fix this without changing much the table (because like I said I want to install that 4chan clone)
You can define column id
as PRIMARY KEY
CREATE TABLE comment(
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
body TEXT NOT NULL,
post_id INT NOT NULL,
posted_at DATETIME NOT NULL,
image_src VARCHAR(255),
board VARCHAR(50) NOT NULL,
FOREIGN KEY(post_id)
REFERENCES post(id)
ON DELETE CASCADE
);
Test it here