起源
在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;
原文地址:https://blog.51cto.com/10983441/2420746
时间: 2024-10-19 08:09:45