Trying to make a migration to drop composed unique key fails without errors.
I've created a migration with php artisan make:migration
and edited the code. So I have this
public function up()
{
Schema::table('ques_trilha_itens', function (Blueprint $table) {
$table->dropUnique('trilha_itens_trilha_id_questao_id_unique');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('ques_trilha_itens', function (Blueprint $table) {
$table->unique(['trilha_id', 'questao_id']);
});
}
The string 'trilha_itens_trilha_id_questao_id_unique'
is the one that is displayed as the composed unique key in MySQL. So I think that string is to be used do drop the two composed keys.
But when running php artisan migrate
, nothing happens, no error messages, and the migration is not executed.
I tried substitute the string in dropUnique
to give the table's name as the first term ('ques_trilha_itens_trilha_id_questao_id_unique'
) and nothing.
Is something I'm missing?
UPDATE:
MySQL command SHOW CREATE TABLE ques_trilha_itens
give:
CREATE TABLE `ques_trilha_itens` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`trilha_id` int(10) unsigned NOT NULL,
`questao_id` int(10) unsigned NOT NULL,
`primeiro_item` tinyint(1) NOT NULL,
`item_principal_id` int(10) unsigned DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`chave` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `trilha_itens_trilha_id_questao_id_unique` (`trilha_id`,`questao_id`),
UNIQUE KEY `ques_trilha_itens_chave_unique` (`chave`),
KEY `trilha_itens_questao_id_foreign` (`questao_id`),
KEY `ques_trilha_itens_item_principal_id_foreign` (`item_principal_id`),
CONSTRAINT `ques_trilha_itens_item_principal_id_foreign` FOREIGN KEY (`item_principal_id`) REFERENCES `ques_trilha_itens` (`id`) ON DELETE SET NULL,
CONSTRAINT `trilha_itens_trilha_id_foreign` FOREIGN KEY (`trilha_id`) REFERENCES `ques_trilhas` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci