[bug][v12][patch] mysql query to create primary key in tabSeries unsuccessful due to duplicate entries
See original GitHub issueThe following query to create a primary key in tabSeries fails due to there being duplicate entries in the table.
ALTER table `tabSeries` ADD PRIMARY KEY IF NOT EXISTS (name)
Reference: https://github.com/frappe/frappe/blob/develop/frappe/patches.txt#L233
Duplicate entries in this table may occur due to older implementations. But they have the exact same values in columns name
and current
.
To fix this issue, refer to: https://stackoverflow.com/a/8147103
Tagging dev: @sunnyakaxd
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
MySQL duplicate entry error even though there is no duplicate ...
It is not created due to a primary key existing that was never actually created or due to damage to the table. What...
Read more >MySQL Replication Duplicate Entry for Primary Key
You cannot continue with that query, since primary key column is a unique column, it does not accept duplicate values.
Read more >13.2.7.2 INSERT ... ON DUPLICATE KEY UPDATE Statement
If you specify an ON DUPLICATE KEY UPDATE clause and a row to be inserted would cause a duplicate value in a UNIQUE...
Read more >MySQL - Handling Duplicates - Tutorialspoint
Let us take an example – The following table contains no such index or primary key, so it would allow duplicate records for...
Read more >INSERT ON DUPLICATE KEY UPDATE - MariaDB
ON DUPLICATE KEY UPDATE is a MariaDB/MySQL extension to the INSERT ... A regular INSERT with a primary key value of 1 will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have added this PR to fix the same. It’ll deduplicate the
tabSeries
table initially before making primary keyhttps://github.com/frappe/frappe/pull/6498
Having tried it in
bench console
, I can verify that this does the job. Thanks.