Skip to content

Commit

Permalink
fix(sqlite): Remove some old SQLite cheats
Browse files Browse the repository at this point in the history
- Doctrine correctly forces integer for autoincrement by now
- Doctrine correctly maintains integer types by now

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Sep 29, 2023
1 parent 6ebecc6 commit b59e769
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
11 changes: 0 additions & 11 deletions lib/private/DB/SQLiteMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
namespace OC\DB;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\BigIntType;
use Doctrine\DBAL\Types\Type;

class SQLiteMigrator extends Migrator {
/**
Expand All @@ -34,21 +32,12 @@ class SQLiteMigrator extends Migrator {
* @return \Doctrine\DBAL\Schema\SchemaDiff
*/
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
$platform = $connection->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer');
$platform->registerDoctrineTypeMapping('smallint unsigned', 'integer');
$platform->registerDoctrineTypeMapping('varchar ', 'string');

foreach ($targetSchema->getTables() as $table) {
foreach ($table->getColumns() as $column) {
// column comments are not supported on SQLite
if ($column->getComment() !== null) {
$column->setComment(null);
}
// with sqlite autoincrement columns is of type integer
if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) {
$column->setType(Type::getType('integer'));
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions tests/lib/DB/MigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ private function getSchemaConfig() {
return $config;
}

private function isSQLite() {
return $this->connection->getDatabasePlatform() instanceof SqlitePlatform;
}

public function testUpgrade() {
[$startSchema, $endSchema] = $this->getDuplicateKeySchemas();
$migrator = $this->getMigrator();
Expand Down

0 comments on commit b59e769

Please sign in to comment.