diff options
Diffstat (limited to 'lib/private/db/sqlitemigrator.php')
-rw-r--r-- | lib/private/db/sqlitemigrator.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/private/db/sqlitemigrator.php b/lib/private/db/sqlitemigrator.php index f5f78986771..94b421c5562 100644 --- a/lib/private/db/sqlitemigrator.php +++ b/lib/private/db/sqlitemigrator.php @@ -9,8 +9,24 @@ namespace OC\DB; use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Schema\Schema; class SQLiteMigrator extends Migrator { + + /** + * @var \OCP\IConfig + */ + private $config; + + /** + * @param \Doctrine\DBAL\Connection $connection + * @param \OCP\IConfig $config + */ + public function __construct(\Doctrine\DBAL\Connection $connection, \OCP\IConfig $config) { + parent::__construct($connection); + $this->config = $config; + } + /** * @param \Doctrine\DBAL\Schema\Schema $targetSchema * @throws \OC\DB\MigrationException @@ -19,7 +35,7 @@ class SQLiteMigrator extends Migrator { */ public function checkMigrate(\Doctrine\DBAL\Schema\Schema $targetSchema) { $dbFile = $this->connection->getDatabase(); - $tmpFile = \OC_Helper::tmpFile('.db'); + $tmpFile = $this->buildTempDatabase(); copy($dbFile, $tmpFile); $connectionParams = array( @@ -37,4 +53,25 @@ class SQLiteMigrator extends Migrator { throw new MigrationException('', $e->getMessage()); } } + + /** + * @return string + */ + private function buildTempDatabase() { + $dataDir = $this->config->getSystemValue("datadirectory", \OC::$SERVERROOT . '/data'); + $tmpFile = uniqid("oc_"); + return "$dataDir/$tmpFile.db"; + } + + /** + * @param Schema $targetSchema + * @param \Doctrine\DBAL\Connection $connection + * @return \Doctrine\DBAL\Schema\SchemaDiff + */ + protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { + $platform = $connection->getDatabasePlatform(); + $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer'); + + return parent::getDiff($targetSchema, $connection); + } } |