I'm trying to create a table with different foreign key constraints but mysql complains about this DDL:
CREATE TABLE tasks (
id INTEGER NOT NULL AUTO_INCREMENT,
`createdAt` DATETIME NOT NULL DEFAULT now(),
`updatedAt` DATETIME NOT NULL DEFAULT NOW() ON UPDATE NOW(),
`createdBy_user_id` INTEGER NOT NULL,
`updatedBy_user_id` INTEGER NOT NULL,
status ENUM('open','closed') NOT NULL,
customer_id INTEGER NOT NULL,
`projectDescription` TEXT,
PRIMARY KEY (id),
CONSTRAINT user_id_fk FOREIGN KEY(`createdBy_user_id`) REFERENCES users (id),
CONSTRAINT customer_id_fk FOREIGN KEY(customer_id) REFERENCES `Customer` (id),
CONSTRAINT user_up_id_fk FOREIGN KEY(`updatedBy_user_id`) REFERENCES users (id)
)COLLATE utf8mb4_german2_ci CHARSET=utf8mb4
I get the error ERROR 1022 (23000): Can't write; duplicate key in table 'tasks'
that makes no sense because every constraint has a different name and is applied on different columns.
Strangely MySQL does not complain if i remove the fk
-suffix and replace it by something like constr
.
Does anybode know why MySQL 5.7 (Server version: 5.7.30-33 Percona Server (GPL), Release 33, Revision 6517692
) behaves like this?