Fixed issue, that users table were delete while PartKeepr import on certain databases

This fixes issue #299
This commit is contained in:
Jan Böhmer 2023-06-11 00:31:05 +02:00
parent 44cb0fa434
commit ab11747fab
2 changed files with 7 additions and 2 deletions

View file

@ -176,6 +176,11 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
continue; continue;
} }
// The table name might be quoted, we have to trim it
// See https://github.com/Part-DB/Part-DB-server/issues/299
$tbl = trim($tbl, '"');
$tbl = trim($tbl, '`');
// If the table is excluded, skip it as well // If the table is excluded, skip it as well
if (in_array($tbl, $this->excluded, true)) { if (in_array($tbl, $this->excluded, true)) {
continue; continue;

View file

@ -43,8 +43,8 @@ class PKImportHelper
*/ */
public function purgeDatabaseForImport(): void public function purgeDatabaseForImport(): void
{ {
//Versions with "" are needed !! //We use the ResetAutoIncrementORMPurger to reset the auto increment values of the tables. Also it normalizes table names before checking for exclusion.
$purger = new ResetAutoIncrementORMPurger($this->em, ['users', '"users"', 'groups', '"groups"', 'u2f_keys', 'internal', 'migration_versions']); $purger = new ResetAutoIncrementORMPurger($this->em, ['users', 'groups', 'u2f_keys', 'internal', 'migration_versions']);
$purger->purge(); $purger->purge();
} }