|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Christoph Wurst <[email protected]> |
|
6
|
|
|
* @author Morris Jobke <[email protected]> |
|
7
|
|
|
* @author Robin Appelman <[email protected]> |
|
8
|
|
|
* @author Thomas Müller <[email protected]> |
|
9
|
|
|
* @author Victor Dubiniuk <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* @license AGPL-3.0 |
|
12
|
|
|
* |
|
13
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
14
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
15
|
|
|
* as published by the Free Software Foundation. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace OC\DB; |
|
28
|
|
|
|
|
29
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
30
|
|
|
use Doctrine\DBAL\Types\BigIntType; |
|
31
|
|
|
use Doctrine\DBAL\Types\Type; |
|
32
|
|
|
|
|
33
|
|
|
class SQLiteMigrator extends Migrator { |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param Schema $targetSchema |
|
37
|
|
|
* @param \Doctrine\DBAL\Connection $connection |
|
38
|
|
|
* @return \Doctrine\DBAL\Schema\SchemaDiff |
|
39
|
|
|
*/ |
|
40
|
|
|
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { |
|
41
|
|
|
$platform = $connection->getDatabasePlatform(); |
|
42
|
|
|
$platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer'); |
|
43
|
|
|
$platform->registerDoctrineTypeMapping('smallint unsigned', 'integer'); |
|
44
|
|
|
$platform->registerDoctrineTypeMapping('varchar ', 'string'); |
|
45
|
|
|
|
|
46
|
|
|
// with sqlite autoincrement columns is of type integer |
|
47
|
|
|
foreach ($targetSchema->getTables() as $table) { |
|
48
|
|
|
foreach ($table->getColumns() as $column) { |
|
49
|
|
|
if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) { |
|
50
|
|
|
$column->setType(Type::getType('integer')); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return parent::getDiff($targetSchema, $connection); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|