views:

39

answers:

1

I have the following dump:

CREATE TABLE  `testdata`.`carer` (
  `ID` bigint(20) NOT NULL auto_increment,
  `IS_DELETED` bit(1) default NULL,
  `name` varchar(255) default NULL,
  `account_id` bigint(20) NOT NULL,
  `patient_carer_id` bigint(20) NOT NULL,
  PRIMARY KEY  (`ID`),
  KEY `FK5A0E781D4C45C51` (`patient_carer_id`),
  KEY `FK5A0E7818BCEF0FB` (`account_id`),
  CONSTRAINT `FK5A0E781D4C45C51` FOREIGN KEY (`patient_carer_id`) REFERENCES `patients` (`ID`),
  CONSTRAINT `FK5A0E7818BCEF0FB` FOREIGN KEY (`account_ID`) REFERENCES `account` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8

but as result i see the following: ERROR 1061 (42000): Duplicate key name 'FK5A0E7818BCEF0FB'

Yep, key's name and constrain's name are same. But with other key we haven't any problems. But if I'll change KEY FK5A0E7818BCEF0FB to FK5A0E7818BCEF0FB1 , it will be working.

for more information, dumps of two other tables:

CREATE TABLE  `testdata`.`account` (
  `ID` bigint(20) NOT NULL auto_increment,
  `IS_DELETED` bit(1) default NULL,
  `name` varchar(255) NOT NULL,
  `template` varchar(255) default NULL,
  `logoCache` bigint(20) default NULL,
  `suspended` bit(1) default NULL,
  `contactPerson` varchar(255) default NULL,
  `contactPersonPosition` varchar(255) default NULL,
  `clearLogo` bit(1) default NULL,
  `scheduling_settings_id` bigint(20) default NULL,
  `billing_id` bigint(20) default NULL,
  `settingsId` bigint(20) default NULL,
  `geocodingProvider_ID` bigint(20) default NULL,
  `mapProvider_ID` bigint(20) default NULL,
  `salesChannel_ID` bigint(20) default NULL,
  `available_time_id` bigint(20) default NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `scheduling_settings_id` (`scheduling_settings_id`),
  UNIQUE KEY `billing_id` (`billing_id`),
  UNIQUE KEY `settingsId` (`settingsId`),
  KEY `FKB9D38A2DBF9BE64A` (`mapProvider_ID`),
  KEY `FKB9D38A2D64C6436C` (`billing_id`),
  KEY `FKB9D38A2DBAC9B04B` (`geocodingProvider_ID`),
  KEY `FKB9D38A2D641A10EA` (`available_time_id`),
  KEY `FKB9D38A2D7D7F6D28` (`settingsId`),
  KEY `FKB9D38A2D44D2DE01` (`scheduling_settings_id`),
  KEY `FKB9D38A2D9A025321` (`salesChannel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8




CREATE TABLE  `testdata`.`patients` (
  `ID` bigint(20) NOT NULL auto_increment,
  `IS_DELETED` bit(1) default NULL,
  `gpName` varchar(255) default NULL,
  `title` varchar(255) default NULL,
  `firstName` varchar(255) NOT NULL,
  `lastName` varchar(255) NOT NULL,
  `nhsNumber` varchar(255) NOT NULL,
  `sex` varchar(255) default NULL,
  `dateOfBirth` datetime default NULL,
  `weight` varchar(255) default NULL,
  `notificationMethod` varchar(255) default NULL,
  `ethnicity_id` bigint(20) default NULL,
  `mobilityCode_ID` bigint(20) default NULL,
  `homeLocation_ID` bigint(20) default NULL,
  `account_id` bigint(20) NOT NULL,
  `original_patient_id` bigint(20) default NULL,
  PRIMARY KEY  (`ID`),
  KEY `FK49A9760E511FA9D3` (`ethnicity_id`),
  KEY `FK49A9760E8BCEF0FB` (`account_id`),
  KEY `FK49A9760EC7B193C1` (`mobilityCode_ID`),
  KEY `FK49A9760EC0EFD76E` (`homeLocation_ID`),
  KEY `FK49A9760ED05CD81` (`original_patient_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2434 DEFAULT CHARSET=utf8
+1  A: 

You're hitting mysql bugs 39932 and 45307.

Instead of

CONSTRAINT `FK5A0E7818BCEF0FB` FOREIGN KEY (`account_ID`) REFERENCES `account` (`ID`)

try

CONSTRAINT `FK5A0E7818BCEF0FB` FOREIGN KEY (`account_id`) REFERENCES `account` (`ID`)

Note the change of case of account_id.

Many thanks! It's great ans!KEY `FK5A0E7818BCEF0FB` (`account_id`),CONSTRAINT `FK5A0E7818BCEF0FB` FOREIGN KEY (`account_ID`) REFERENCES `account` (`ID`)(`account_id`) it first line should be the same with (`account_ID`), but it didn't.
Max