mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 10:24:31 +02:00
Reset autoincrements on SQLite with our ResetAutoIncrementPurger too and make it default for fixtures load
This commit is contained in:
parent
fe1715259a
commit
4977f6c270
3 changed files with 20 additions and 4 deletions
|
@ -27,6 +27,7 @@ use Doctrine\Common\DataFixtures\Purger\PurgerInterface;
|
|||
use Doctrine\Common\DataFixtures\Sorter\TopologicalSorter;
|
||||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
use Doctrine\DBAL\Schema\Identifier;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
|
@ -188,7 +189,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
|
|||
}
|
||||
|
||||
//Reseting autoincrement is only supported on MySQL platforms
|
||||
if ($platform instanceof AbstractMySQLPlatform) {
|
||||
if ($platform instanceof AbstractMySQLPlatform || $platform instanceof SqlitePlatform) {
|
||||
$connection->beginTransaction();
|
||||
$connection->executeQuery($this->getResetAutoIncrementSQL($tbl, $platform));
|
||||
}
|
||||
|
@ -204,7 +205,13 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
|
|||
{
|
||||
$tableIdentifier = new Identifier($tableName);
|
||||
|
||||
return 'ALTER TABLE '. $tableIdentifier->getQuotedName($platform) .' AUTO_INCREMENT = 1;';
|
||||
if ($platform instanceof AbstractMySQLPlatform) {
|
||||
return 'ALTER TABLE '.$tableIdentifier->getQuotedName($platform).' AUTO_INCREMENT = 1;';
|
||||
}
|
||||
|
||||
if ($platform instanceof SqlitePlatform) {
|
||||
return 'DELETE FROM `sqlite_sequence` WHERE name = \''.$tableIdentifier->getQuotedName($platform).'\';';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue