From fe8bae31dc80ac832323fa8d9a75fd4b543d36e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 17 Apr 2014 16:12:48 +0200 Subject: [PATCH] adding PK to table encryption adding auto increment/PK to table files_trash adding PK to table ldap_user_mapping and ldap_group_members adding PK to table ldap_group_mapping truncate permissions table to allow smooth creation of primary key adding unit test for creating an auto increment column on a table which already contains data remove unneeded table files_trashsizes fix unit test no need to truncate *PREFIX*permissions On Oracle adding auto increment columns is not working out of the box - Oracle migrations are to be done manually --- apps/files_trashbin/appinfo/database.xml | 9 ++++++ apps/files_trashbin/appinfo/version | 2 +- apps/user_ldap/appinfo/database.xml | 5 +++- lib/private/db/mdb2schemamanager.php | 2 +- lib/private/updater.php | 1 + tests/lib/db/mdb2schemamanager.php | 37 ++++++++++++++++++++++++ tests/lib/db/ts-autoincrement-after.xml | 32 ++++++++++++++++++++ tests/lib/db/ts-autoincrement-before.xml | 24 +++++++++++++++ 8 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 tests/lib/db/mdb2schemamanager.php create mode 100644 tests/lib/db/ts-autoincrement-after.xml create mode 100644 tests/lib/db/ts-autoincrement-before.xml diff --git a/apps/files_trashbin/appinfo/database.xml b/apps/files_trashbin/appinfo/database.xml index a6ba242c1c..2944a31b02 100644 --- a/apps/files_trashbin/appinfo/database.xml +++ b/apps/files_trashbin/appinfo/database.xml @@ -13,6 +13,15 @@ + + auto_id + integer + 0 + true + 1 + 4 + + id text diff --git a/apps/files_trashbin/appinfo/version b/apps/files_trashbin/appinfo/version index 5a2a5806df..ee6cdce3c2 100644 --- a/apps/files_trashbin/appinfo/version +++ b/apps/files_trashbin/appinfo/version @@ -1 +1 @@ -0.6 +0.6.1 diff --git a/apps/user_ldap/appinfo/database.xml b/apps/user_ldap/appinfo/database.xml index 812e450dde..4875a70f85 100644 --- a/apps/user_ldap/appinfo/database.xml +++ b/apps/user_ldap/appinfo/database.xml @@ -46,6 +46,7 @@ owncloud_name_users + true true owncloud_name @@ -90,6 +91,7 @@ ldap_dn_groups true + true ldap_dn @@ -132,6 +134,7 @@ ldap_group_members_index true + true owncloudname @@ -141,4 +144,4 @@ - \ No newline at end of file + diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php index 734ba18d1a..ee3d53b576 100644 --- a/lib/private/db/mdb2schemamanager.php +++ b/lib/private/db/mdb2schemamanager.php @@ -109,7 +109,7 @@ class MDB2SchemaManager { */ public function simulateUpdateDbFromStructure($file) { $toSchema = $this->readSchemaFromFile($file); - $migrator = $this->getMigrator()->checkMigrate($toSchema); + $this->getMigrator()->checkMigrate($toSchema); return true; } diff --git a/lib/private/updater.php b/lib/private/updater.php index 58a4086c80..9cc1b3322e 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -150,6 +150,7 @@ class Updater extends BasicEmitter { // This is added to prevent host header poisoning \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost()))); } + /* * STOP CONFIG CHANGES FOR OLDER VERSIONS */ diff --git a/tests/lib/db/mdb2schemamanager.php b/tests/lib/db/mdb2schemamanager.php new file mode 100644 index 0000000000..51e3c7002f --- /dev/null +++ b/tests/lib/db/mdb2schemamanager.php @@ -0,0 +1,37 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\DB; + +class MDB2SchemaManager extends \PHPUnit_Framework_TestCase { + + public function tearDown() { + \OC_DB::dropTable('table'); + } + + public function testAutoIncrement() { + + if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { + $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.'); + } + + $connection = \OC_DB::getConnection(); + $manager = new \OC\DB\MDB2SchemaManager($connection); + + $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml'); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); + $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml'); + + $this->assertTrue(true); + } + +} diff --git a/tests/lib/db/ts-autoincrement-after.xml b/tests/lib/db/ts-autoincrement-after.xml new file mode 100644 index 0000000000..d4445f1e24 --- /dev/null +++ b/tests/lib/db/ts-autoincrement-after.xml @@ -0,0 +1,32 @@ + + + + *dbname* + true + false + + utf8 + + + + *dbprefix*table + + + + auto_id + integer + 0 + true + 1 + 4 + + + textfield + text + foo + true + 32 + + +
+
diff --git a/tests/lib/db/ts-autoincrement-before.xml b/tests/lib/db/ts-autoincrement-before.xml new file mode 100644 index 0000000000..412739e9a7 --- /dev/null +++ b/tests/lib/db/ts-autoincrement-before.xml @@ -0,0 +1,24 @@ + + + + *dbname* + true + false + + utf8 + + + + *dbprefix*table + + + + textfield + text + foo + true + 32 + + +
+