Last active
March 7, 2016 09:34
-
-
Save CTimmerman/8edaf32d6818f354a857 to your computer and use it in GitHub Desktop.
Change columns with constraints in MySQL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
show create table orders_products; | |
ALTER TABLE orders_products DROP FOREIGN KEY orders_products_ibfk_1; | |
alter table orders_products modify column orderId bigint; | |
alter table orders modify column id bigint AUTO_INCREMENT; | |
ALTER TABLE orders_products ADD CONSTRAINT `orders_products_ibfk_1` FOREIGN KEY (`orderId`) REFERENCES `orders` (`id`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As disabling foreign key checks is dangerous and didn't work.