Mysql – “Cannot drop index ‘unique_token_data’: needed in a foreign key constraint” in MySQL without a foreign key

errorsforeign keyMySQLmysql-5.7unique-constraint

When I try to remove a unique index, MySQL Ver 5.7.26-0ubuntu0.19.04.1 says that it is needed in a foreign key constraint:

mysql> ALTER TABLE project_erc20token DROP INDEX unique_token_data;
ERROR 1553 (HY000): Cannot drop index 'unique_token_data': needed in a foreign key constraint

But there is no such foreign key in the DB!

What is the error?

DB dump follows:

-- MySQL dump 10.13  Distrib 5.7.26, for Linux (x86_64)
--
-- Host: localhost    Database: crypto4ngo
-- ------------------------------------------------------
-- Server version   5.7.26-0ubuntu0.19.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `auth_group`
--

DROP TABLE IF EXISTS `auth_group`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `auth_group` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `auth_group`
--

LOCK TABLES `auth_group` WRITE;
/*!40000 ALTER TABLE `auth_group` DISABLE KEYS */;
/*!40000 ALTER TABLE `auth_group` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `auth_group_permissions`
--

DROP TABLE IF EXISTS `auth_group_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `auth_group_permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group_id` int(11) NOT NULL,
  `permission_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `auth_group_permissions_group_id_permission_id_0cd325b0_uniq` (`group_id`,`permission_id`),
  KEY `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm` (`permission_id`),
  CONSTRAINT `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`),
  CONSTRAINT `auth_group_permissions_group_id_b120cbf9_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `auth_group_permissions`
--

LOCK TABLES `auth_group_permissions` WRITE;
/*!40000 ALTER TABLE `auth_group_permissions` DISABLE KEYS */;
/*!40000 ALTER TABLE `auth_group_permissions` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `auth_permission`
--

DROP TABLE IF EXISTS `auth_permission`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `auth_permission` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `content_type_id` int(11) NOT NULL,
  `codename` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `auth_permission_content_type_id_codename_01ab375a_uniq` (`content_type_id`,`codename`),
  CONSTRAINT `auth_permission_content_type_id_2f476e4b_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `auth_permission`
--

LOCK TABLES `auth_permission` WRITE;
/*!40000 ALTER TABLE `auth_permission` DISABLE KEYS */;
/*!40000 ALTER TABLE `auth_permission` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `django_admin_log`
--

DROP TABLE IF EXISTS `django_admin_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `django_admin_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `action_time` datetime(6) NOT NULL,
  `object_id` longtext,
  `object_repr` varchar(200) NOT NULL,
  `action_flag` smallint(5) unsigned NOT NULL,
  `change_message` longtext NOT NULL,
  `content_type_id` int(11) DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `django_admin_log_content_type_id_c4bce8eb_fk_django_co` (`content_type_id`),
  KEY `django_admin_log_user_id_c564eba6_fk_user_user_id` (`user_id`),
  CONSTRAINT `django_admin_log_content_type_id_c4bce8eb_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`),
  CONSTRAINT `django_admin_log_user_id_c564eba6_fk_user_user_id` FOREIGN KEY (`user_id`) REFERENCES `user_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `django_admin_log`
--

LOCK TABLES `django_admin_log` WRITE;
/*!40000 ALTER TABLE `django_admin_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `django_admin_log` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `django_content_type`
--

DROP TABLE IF EXISTS `django_content_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `django_content_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `app_label` varchar(100) NOT NULL,
  `model` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `django_content_type_app_label_model_76bd3d3b_uniq` (`app_label`,`model`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `django_content_type`
--

LOCK TABLES `django_content_type` WRITE;
/*!40000 ALTER TABLE `django_content_type` DISABLE KEYS */;
/*!40000 ALTER TABLE `django_content_type` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `django_migrations`
--

DROP TABLE IF EXISTS `django_migrations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `django_migrations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `app` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `applied` datetime(6) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `django_migrations`
--

LOCK TABLES `django_migrations` WRITE;
/*!40000 ALTER TABLE `django_migrations` DISABLE KEYS */;
INSERT INTO `django_migrations` VALUES (1,'contenttypes','0001_initial','2019-06-02 23:48:08.042378'),(2,'contenttypes','0002_remove_content_type_name','2019-06-02 23:48:08.109635'),(3,'auth','0001_initial','2019-06-02 23:48:08.175753'),(4,'auth','0002_alter_permission_name_max_length','2019-06-02 23:48:08.340695'),(5,'auth','0003_alter_user_email_max_length','2019-06-02 23:48:08.355964'),(6,'auth','0004_alter_user_username_opts','2019-06-02 23:48:08.365035'),(7,'auth','0005_alter_user_last_login_null','2019-06-02 23:48:08.372186'),(8,'auth','0006_require_contenttypes_0002','2019-06-02 23:48:08.374797'),(9,'auth','0007_alter_validators_add_error_messages','2019-06-02 23:48:08.379832'),(10,'auth','0008_alter_user_username_max_length','2019-06-02 23:48:08.386091'),(11,'auth','0009_alter_user_last_name_max_length','2019-06-02 23:48:08.391981'),(12,'user','0001_initial','2019-06-02 23:48:08.454908'),(13,'admin','0001_initial','2019-06-02 23:48:08.702918'),(14,'admin','0002_logentry_remove_auto_add','2019-06-02 23:48:08.814770'),(15,'admin','0003_logentry_add_action_flag_choices','2019-06-02 23:48:08.837096'),(16,'auth','0010_alter_group_name_max_length','2019-06-02 23:48:08.853074'),(17,'auth','0011_update_proxy_permissions','2019-06-02 23:48:08.864174'),(18,'project','0001_initial','2019-06-02 23:48:08.907983'),(19,'project','0002_project_user','2019-06-02 23:48:09.008687'),(20,'project','0003_auto_20180329_0214','2019-06-02 23:48:09.147515'),(21,'project','0004_auto_20180330_0432','2019-06-02 23:48:09.221409'),(22,'project','0005_auto_20180331_2048','2019-06-02 23:48:09.296913'),(23,'project','0006_project_disabled','2019-06-02 23:48:09.352610'),(24,'project','0007_auto_20180405_1811','2019-06-02 23:48:09.492833'),(25,'project','0008_projectversion_owner','2019-06-02 23:48:09.538680'),(26,'project','0009_auto_20180405_1957','2019-06-02 23:48:09.600958'),(27,'project','0010_auto_20180405_1958','2019-06-02 23:48:09.666514'),(28,'project','0011_auto_20181212_0029','2019-06-02 23:48:09.733264'),(29,'project','0012_auto_20190426_1926','2019-06-02 23:48:09.753808'),(30,'project','0013_paymenturls','2019-06-02 23:48:09.785307'),(31,'project','0014_auto_20190427_1253','2019-06-02 23:48:09.899803'),(32,'project','0015_auto_20190427_1255','2019-06-02 23:48:09.955520'),(33,'project','0016_auto_20190427_1256','2019-06-02 23:48:10.028208'),(34,'project','0017_auto_20190427_1308','2019-06-02 23:48:10.088524'),(35,'project','0018_auto_20190510_1306','2019-06-02 23:48:10.169626'),(36,'project','0019_auto_20190510_1319','2019-06-02 23:48:10.294121'),(37,'project','0020_auto_20190510_1406','2019-06-02 23:48:10.319996'),(38,'project','0021_auto_20190523_1329','2019-06-02 23:48:10.329473'),(39,'project','0022_auto_20190524_0749','2019-06-02 23:48:10.508430'),(40,'project','0023_auto_20190525_1012','2019-06-02 23:48:10.518815'),(41,'project','0024_auto_20190525_2307','2019-06-02 23:48:10.531579'),(42,'project','0025_auto_20190526_0752','2019-06-02 23:48:10.538459'),(43,'project','0026_auto_20190527_0238','2019-06-02 23:48:10.705232'),(44,'project','0027_project_current_erc20_wallet','2019-06-02 23:48:10.860732'),(45,'project','0028_auto_20190527_1941','2019-06-02 23:48:10.955087'),(46,'project','0029_remove_project_current_erc20_token','2019-06-02 23:48:10.994059');
/*!40000 ALTER TABLE `django_migrations` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `project_erc20token`
--

DROP TABLE IF EXISTS `project_erc20token`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_erc20token` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime(6) NOT NULL,
  `owner` varchar(42) NOT NULL,
  `contract_address` varchar(42) NOT NULL,
  `contract_symbol` varchar(255) NOT NULL,
  `contract_name` varchar(255) NOT NULL,
  `project_id` int(11) NOT NULL,
  `wallet_id` int(11) DEFAULT NULL,
  `unqiue_hack` char(32) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_token_data` (`project_id`,`contract_address`,`contract_symbol`,`contract_name`,`owner`),
  UNIQUE KEY `unqiue_hack` (`unqiue_hack`),
  UNIQUE KEY `wallet_id` (`wallet_id`),
  CONSTRAINT `project_erc20token_project_id_d389b8fb_fk_project_project_id` FOREIGN KEY (`project_id`) REFERENCES `project_project` (`id`),
  CONSTRAINT `project_erc20token_wallet_id_db01a319_fk_project_e` FOREIGN KEY (`wallet_id`) REFERENCES `project_ethereumwallet` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `project_erc20token`
--

LOCK TABLES `project_erc20token` WRITE;
/*!40000 ALTER TABLE `project_erc20token` DISABLE KEYS */;
/*!40000 ALTER TABLE `project_erc20token` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `project_ethereumwallet`
--

DROP TABLE IF EXISTS `project_ethereumwallet`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_ethereumwallet` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime(6) NOT NULL,
  `address` varchar(42) NOT NULL,
  `project_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_ethereum_data` (`project_id`,`address`),
  CONSTRAINT `project_ethereumwallet_project_id_f02b3077_fk_project_project_id` FOREIGN KEY (`project_id`) REFERENCES `project_project` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `project_ethereumwallet`
--

LOCK TABLES `project_ethereumwallet` WRITE;
/*!40000 ALTER TABLE `project_ethereumwallet` DISABLE KEYS */;
/*!40000 ALTER TABLE `project_ethereumwallet` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `project_paymenturl`
--

DROP TABLE IF EXISTS `project_paymenturl`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_paymenturl` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order` int(10) unsigned NOT NULL,
  `url` varchar(200) NOT NULL,
  `title` varchar(255) NOT NULL,
  `project_version_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `project_paymenturls_order_7c405be4` (`order`),
  KEY `project_paymenturls_project_version_id_82ae8cc8_fk_project_p` (`project_version_id`),
  CONSTRAINT `project_paymenturls_project_version_id_82ae8cc8_fk_project_p` FOREIGN KEY (`project_version_id`) REFERENCES `project_projectversion` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `project_paymenturl`
--

LOCK TABLES `project_paymenturl` WRITE;
/*!40000 ALTER TABLE `project_paymenturl` DISABLE KEYS */;
/*!40000 ALTER TABLE `project_paymenturl` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `project_project`
--

DROP TABLE IF EXISTS `project_project`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime(6) NOT NULL,
  `updated` datetime(6) NOT NULL,
  `user_id` int(11) NOT NULL,
  `disabled` tinyint(1) NOT NULL,
  `current_erc20_wallet_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_project_user_id_8710107a_fk_user_user_id` (`user_id`),
  KEY `project_project_current_erc20_wallet_6187e471_fk_project_e` (`current_erc20_wallet_id`),
  CONSTRAINT `project_project_current_erc20_wallet_6187e471_fk_project_e` FOREIGN KEY (`current_erc20_wallet_id`) REFERENCES `project_ethereumwallet` (`id`),
  CONSTRAINT `project_project_user_id_8710107a_fk_user_user_id` FOREIGN KEY (`user_id`) REFERENCES `user_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `project_project`
--

LOCK TABLES `project_project` WRITE;
/*!40000 ALTER TABLE `project_project` DISABLE KEYS */;
/*!40000 ALTER TABLE `project_project` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `project_projectversion`
--

DROP TABLE IF EXISTS `project_projectversion`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_projectversion` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime(6) NOT NULL,
  `title` varchar(200) NOT NULL,
  `description` longtext NOT NULL,
  `money_usage` longtext NOT NULL,
  `allow_advertisement` tinyint(1) NOT NULL,
  `allow_press_releases` tinyint(1) NOT NULL,
  `ownership` smallint(6) NOT NULL,
  `country` varchar(2) NOT NULL,
  `organization_name` varchar(255) NOT NULL,
  `organization_number` varchar(20) NOT NULL,
  `project_id` int(11) NOT NULL,
  `url` varchar(200) NOT NULL,
  `bitcoin_address` varchar(35) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `project_projectversion_project_id_b2445cad_fk_project_project_id` (`project_id`),
  CONSTRAINT `project_projectversion_project_id_b2445cad_fk_project_project_id` FOREIGN KEY (`project_id`) REFERENCES `project_project` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `project_projectversion`
--

LOCK TABLES `project_projectversion` WRITE;
/*!40000 ALTER TABLE `project_projectversion` DISABLE KEYS */;
/*!40000 ALTER TABLE `project_projectversion` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `user_user`
--

DROP TABLE IF EXISTS `user_user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `password` varchar(128) NOT NULL,
  `last_login` datetime(6) DEFAULT NULL,
  `is_superuser` tinyint(1) NOT NULL,
  `username` varchar(150) NOT NULL,
  `first_name` varchar(30) NOT NULL,
  `last_name` varchar(150) NOT NULL,
  `email` varchar(254) NOT NULL,
  `is_staff` tinyint(1) NOT NULL,
  `is_active` tinyint(1) NOT NULL,
  `date_joined` datetime(6) NOT NULL,
  `ssh_pubkey` longtext NOT NULL,
  `pgp_pubkey` longtext NOT NULL,
  `show_email` tinyint(1) NOT NULL,
  `show_keys` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `user_user`
--

LOCK TABLES `user_user` WRITE;
/*!40000 ALTER TABLE `user_user` DISABLE KEYS */;
/*!40000 ALTER TABLE `user_user` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `user_user_groups`
--

DROP TABLE IF EXISTS `user_user_groups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_user_groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_user_groups_user_id_group_id_bb60391f_uniq` (`user_id`,`group_id`),
  KEY `user_user_groups_group_id_c57f13c0_fk_auth_group_id` (`group_id`),
  CONSTRAINT `user_user_groups_group_id_c57f13c0_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`),
  CONSTRAINT `user_user_groups_user_id_13f9a20d_fk_user_user_id` FOREIGN KEY (`user_id`) REFERENCES `user_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `user_user_groups`
--

LOCK TABLES `user_user_groups` WRITE;
/*!40000 ALTER TABLE `user_user_groups` DISABLE KEYS */;
/*!40000 ALTER TABLE `user_user_groups` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `user_user_user_permissions`
--

DROP TABLE IF EXISTS `user_user_user_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_user_user_permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `permission_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_user_user_permissions_user_id_permission_id_64f4d5b8_uniq` (`user_id`,`permission_id`),
  KEY `user_user_user_permi_permission_id_ce49d4de_fk_auth_perm` (`permission_id`),
  CONSTRAINT `user_user_user_permi_permission_id_ce49d4de_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`),
  CONSTRAINT `user_user_user_permissions_user_id_31782f58_fk_user_user_id` FOREIGN KEY (`user_id`) REFERENCES `user_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `user_user_user_permissions`
--

LOCK TABLES `user_user_user_permissions` WRITE;
/*!40000 ALTER TABLE `user_user_user_permissions` DISABLE KEYS */;
/*!40000 ALTER TABLE `user_user_user_permissions` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Dumping events for database 'crypto4ngo'
--

--
-- Dumping routines for database 'crypto4ngo'
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2019-06-03  3:06:39

Best Answer

Reason : When you drop an index, InnoDB checks if the index is used for checking a foreign key constraint. It is still OK to drop the index if there is another index that can be used to enforce the same constraint. InnoDB prevents you from dropping the last index that can enforce a particular referential constraint.[Reference: https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html]

Here in table we have foreign key on project_id column for its reference unique_token_data index is used. Due to this reason server is not allowing to drop unique index.

Try This :

Add index IDX_token_data on project_erc20token (`project_id`) algorithm=inplace;

ALTER TABLE project_erc20token DROP INDEX unique_token_data;