New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database: add primary key to device_graphs #11323
Conversation
*/ | ||
public function up() | ||
{ | ||
DB::table('device_graphs')->delete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't be right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that table might contain duplicates, as no constraint prevented that. Thus, clear the table, then add the primary key. Also, poller modules will fill the table upon next run. Am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rkojedzinszky you can run through and delete duplicates first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, on a table without a primary key, you cannot delete just duplicates. You cannot identify them :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new column with a primary key first then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I am not a php developer, and perhaps, a bigger refactor would be needed here, which I cannot handle. The original problem involves a table without primary key and inserting into it with insert ignore
. This breaks librenms on percona xtradb. Perhaps, the real solution is somewhere else.
IMO, delete duplicates, add primary key id, add unique index on device_id and graph. |
Percona Xtradb refused to INSERT IGNORE into a table without a primary key.
Percona Xtradb refused to INSERT IGNORE into a table
without a primary key.
DO NOT DELETE THIS TEXT
Please note
Testers
If you would like to test this pull request then please run:
./scripts/github-apply <pr_id>
, i.e./scripts/github-apply 5926
After you are done testing, you can remove the changes with
./scripts/github-remove
. If there are schema changes, you can ask on discord how to revert.