mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 10:24:31 +02:00
Ensure that the PartKeepr Version is correct.
This commit is contained in:
parent
563d6bccd3
commit
ae438f1650
2 changed files with 30 additions and 0 deletions
|
@ -47,4 +47,28 @@ class PKImportHelper
|
|||
$purger = new ResetAutoIncrementORMPurger($this->em, ['users', '"users"', 'groups', '"groups"', 'u2f_keys', 'internal', 'migration_versions']);
|
||||
$purger->purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the current database schema version from the PartKeepr XML dump.
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function getDatabaseSchemaVersion(array $data): string
|
||||
{
|
||||
if (!isset($data['schemaversions'])) {
|
||||
throw new \RuntimeException('Could not find schema version in XML dump!');
|
||||
}
|
||||
|
||||
return end($data['schemaversions'])['version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the database schema of the PartKeepr XML dump is compatible with the importer
|
||||
* @param array $data
|
||||
* @return bool True if the schema is compatible, false otherwise
|
||||
*/
|
||||
public function checkVersion(array $data): bool
|
||||
{
|
||||
return $this->getDatabaseSchemaVersion($data) === '20170601175559';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue