Duplicate key name > 'web_privilege_name_102618e8_

起源

在models中设置unique,多次migrate就会报下面的信息
  raise errorclass, errorvalue django.db.utils.OperationalError: (1061, "Duplicate key name
> 'web_privilege_name_102618e8_uniq'")

原因

Running migrations:
(0.002) b'SHOW FULL TABLES'; args=None
ALTER TABLE `web_privilege` ADD CONSTRAINT `web_privilege_name_102618e8_uniq` UNIQUE (`name`); (params ())
(0.001) None; args=()

解决方法

mysql> DROP INDEX [index_name] ON [table_name];

即
mysql> DROP INDEX web_privilege_name_102618e8_uniq ON web_privilege;

你可能感兴趣的:(Duplicate key name > 'web_privilege_name_102618e8_)