use database;

set foreign_key_checks=0;

ALTER TABLE `documents` DROP FOREIGN KEY `fk_documents_type_documents_id`;
ALTER TABLE `documents` DROP `type_document_id`;

ALTER TABLE type_documents ENGINE=innoDB;
ALTER TABLE users ENGINE=innoDB;
ALTER TABLE configurations ENGINE=innoDB;

ALTER TABLE `documents` ADD `type_document_id` int(11) DEFAULT NULL;
ALTER TABLE `documents` ADD CONSTRAINT `fk_documents_type_documents_id` FOREIGN KEY (`type_document_id`) REFERENCES `type_documents` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

