guil182 Posted February 13, 2019 Share Posted February 13, 2019 Bonjour, J'essaye de créer un module avec une foreign key. Donc si je desinstalle le module, je veux supprimer la foreign key. $query = "SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'ps_product_attribute_shop' AND column_name = 'id_wineos_attribute'"; $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute($query); if( $results != 0 ){ $sql[] = "SET SQL_MODE='ALLOW_INVALID_DATES'"; $sql[] = 'ALTER TABLE `' . _DB_PREFIX_ . 'product_attribute_shop` ADD `id_wineos_attribute` INT(11) NULL, ADD CONSTRAINT `fk_id_wineos_attribute` FOREIGN KEY (`id_wineos_attribute`) REFERENCES `' . _DB_PREFIX_ . 'wineos_attribute`(`id_wineos_attribute`)'; } Alors que la foreign key n'existe pas, à la reinitialisation du module, cela me met : Error! Exception retournée par le module wineos_attribute pour reset. Erreur lors de la réinitialisation du module wineos_attribute. Can't DROP 'fk_id_wineos_attribute'; check that column/key exists ALTER TABLE `ps_product_attribute_shop` DROP FOREIGN KEY `fk_id_wineos_attribute` Je ne comprends pas...merci de votre aide. Link to comment Share on other sites More sharing options...
Eolia Posted February 13, 2019 Share Posted February 13, 2019 Droppez la contrainte avant de dropper votre table Mais si la primary key de la table de votre module est droppée, la contrainte liée saute automatiquement normalement Link to comment Share on other sites More sharing options...
doekia Posted February 13, 2019 Share Posted February 13, 2019 Et si tu alter, il te faut désactiver le controle des clés 1ere réponse google: https://tableplus.io/blog/2018/08/mysql-how-to-drop-constraint-in-mysql.html Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now