Merge pull request #9888 from owncloud/mysql-tinyint-master
migration test for sqlite - adding type mapping for 'tinyint unsigned'
This commit is contained in:
commit
54d5d03271
3 changed files with 53 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
namespace OC\DB;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
class SQLiteMigrator extends Migrator {
|
||||
|
||||
|
@ -61,4 +62,16 @@ class SQLiteMigrator extends Migrator {
|
|||
$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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
class TestMigration extends \PHPUnit_Framework_TestCase {
|
||||
class TestMySqlMigration extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/** @var \Doctrine\DBAL\Connection */
|
||||
private $connection;
|
39
tests/lib/db/sqlitemigration.php
Normal file
39
tests/lib/db/sqlitemigration.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
class TestSqliteMigration extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/** @var \Doctrine\DBAL\Connection */
|
||||
private $connection;
|
||||
|
||||
/** @var string */
|
||||
private $tableName;
|
||||
|
||||
public function setUp() {
|
||||
$this->connection = \OC_DB::getConnection();
|
||||
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
|
||||
$this->markTestSkipped("Test only relevant on Sqlite");
|
||||
}
|
||||
|
||||
$dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
|
||||
$this->tableName = uniqid($dbPrefix . "_enum_bit_test");
|
||||
$this->connection->exec("CREATE TABLE $this->tableName(t0 tinyint unsigned, t1 tinyint)");
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->connection->getSchemaManager()->dropTable($this->tableName);
|
||||
}
|
||||
|
||||
public function testNonOCTables() {
|
||||
$manager = new \OC\DB\MDB2SchemaManager($this->connection);
|
||||
$manager->updateDbFromStructure(__DIR__ . '/testschema.xml');
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue