Есть 2 таблицы, пытаюсь добавить связь от product->photo_id к photos->product_id
На выходе получаю
#1215 - Невозможно добавить ограничения внешнего ключа
CREATE TABLE `product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`price` int(11) NOT NULL,
`discount` int(11) NOT NULL,
`unit_discount` varchar(255) NOT NULL,
`sku` varchar(255) NOT NULL,
`promocode` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`description` text NOT NULL,
`photo_id` int(11) DEFAULT NULL,
`weight` int(11) NOT NULL,
`unit` varchar(255) NOT NULL,
`property` json NOT NULL,
`date_create` datetime NOT NULL,
`restaurant_id` int(11) NOT NULL,
`creator_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `key_sync_product_to_rest` (`restaurant_id`),
KEY `key_sync_product_to_promo` (`promocode`),
CONSTRAINT `key_sync_product_to_promo` FOREIGN KEY (`promocode`) REFERENCES `promocodes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `key_sync_product_to_rest` FOREIGN KEY (`restaurant_id`) REFERENCES `restaurants` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
CREATE TABLE `photos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) DEFAULT NULL,
`user_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `key_sync_p_to_u` (`user_id`),
CONSTRAINT `key_sync_p_to_u` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
ALTER TABLE `product`
ADD CONSTRAINT `geidicsbbdfdb` FOREIGN KEY (`photo_id`) REFERENCES `photos` (`product_id`) ON DELETE CASCADE ON UPDATE CASCADE