I have a database with the following two columns:
`MainTable`
barcode (PK)
name
I then have another table that FKs to it:
`SubTable`
barcode (FK)
info
How would I add an auto-incrementing Primary Key to the MainTable field, while ensuring barcode uniqueness? Essentially, how would I do the following without a FK error arising?
alter table maintable drop primary key;
alter table maintable add unique key (barcode);
ALTER TABLE `maintable` ADD `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY;