By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE `brand` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(512) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `product` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`ean_code` varchar(255) DEFAULT NULL,
`brand_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `product_eancode_unique` (`brand_id`,`ean_code`),
CONSTRAINT `fk_product_brand_id` FOREIGN KEY (`brand_id`) REFERENCES `brand` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE product ADD INDEX (brand_id),
DROP INDEX product_eancode_unique,
DROP COLUMN `ean_code`;
Records: 0 Duplicates: 0 Warnings: 0