diff --git a/lib/private/db/mysqlmigrator.php b/lib/private/db/mysqlmigrator.php index 97495f520329d6694919d92f5b0788a592c906a7..c0adcdf5df3570a962bd96e3104890699e1f0c9c 100644 --- a/lib/private/db/mysqlmigrator.php +++ b/lib/private/db/mysqlmigrator.php @@ -17,6 +17,10 @@ class MySQLMigrator extends Migrator { * @return \Doctrine\DBAL\Schema\SchemaDiff */ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { + $platform = $connection->getDatabasePlatform(); + $platform->registerDoctrineTypeMapping('enum', 'string'); + $platform->registerDoctrineTypeMapping('bit', 'string'); + $schemaDiff = parent::getDiff($targetSchema, $connection); // identifiers need to be quoted for mysql diff --git a/tests/lib/db/migration.php b/tests/lib/db/migration.php new file mode 100644 index 0000000000000000000000000000000000000000..820a1431f542a303584c973ffec2555e50fe1b07 --- /dev/null +++ b/tests/lib/db/migration.php @@ -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 TestMigration 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\MySqlPlatform) { + $this->markTestSkipped("Test only relevant on MySql"); + } + + $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix"); + $this->tableName = uniqid($dbPrefix . "_enum_bit_test"); + $this->connection->exec("CREATE TABLE $this->tableName(b BIT, e ENUM('1','2','3','4'))"); + } + + 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); + } + +}