]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding PK to table encryption
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 17 Apr 2014 14:12:48 +0000 (16:12 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 6 Jun 2014 11:33:56 +0000 (13:33 +0200)
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
apps/files_trashbin/appinfo/version
apps/user_ldap/appinfo/database.xml
lib/private/db/mdb2schemamanager.php
lib/private/updater.php
tests/lib/db/mdb2schemamanager.php [new file with mode: 0644]
tests/lib/db/ts-autoincrement-after.xml [new file with mode: 0644]
tests/lib/db/ts-autoincrement-before.xml [new file with mode: 0644]

index a6ba242c1cfece11b63cf26855fab43404addf09..2944a31b02d0e7f48abfd758ba2f07ed3d95335f 100644 (file)
 
   <declaration>
 
+         <field>
+                 <name>auto_id</name>
+                 <type>integer</type>
+                 <default>0</default>
+                 <notnull>true</notnull>
+                 <autoincrement>1</autoincrement>
+                 <length>4</length>
+         </field>
+
    <field>
     <name>id</name>
     <type>text</type>
index 5a2a5806df6e909afe3609b5706cb1012913ca0e..ee6cdce3c29053ac99607147be5be250efa001bd 100644 (file)
@@ -1 +1 @@
-0.6
+0.6.1
index 812e450dde7a444acd7eb7592743ea64604cc09a..4875a70f852b136511ec07e1f88777d1f64c2da7 100644 (file)
@@ -46,6 +46,7 @@
 
    <index>
     <name>owncloud_name_users</name>
+          <primary>true</primary>
     <unique>true</unique>
     <field>
      <name>owncloud_name</name>
@@ -90,6 +91,7 @@
    <index>
     <name>ldap_dn_groups</name>
     <unique>true</unique>
+          <primary>true</primary>
     <field>
      <name>ldap_dn</name>
     </field>
    <index>
     <name>ldap_group_members_index</name>
     <unique>true</unique>
+          <primary>true</primary>
     <field>
      <name>owncloudname</name>
     </field>
 
  </table>
 
-</database>
\ No newline at end of file
+</database>
index 734ba18d1ac8688a64ab3ba95b1422263ef9d638..ee3d53b576a4f7b26527431c0b51571ea19fcf12 100644 (file)
@@ -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;
        }
 
index 58a4086c80fd92a47de6cf85c3b3cfedccddc42f..9cc1b3322eb9e1f310a20354270dd951f777d63c 100644 (file)
@@ -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 (file)
index 0000000..51e3c70
--- /dev/null
@@ -0,0 +1,37 @@
+<?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.
+ */
+
+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 (file)
index 0000000..d4445f1
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<database>
+
+       <name>*dbname*</name>
+       <create>true</create>
+       <overwrite>false</overwrite>
+
+       <charset>utf8</charset>
+
+       <table>
+
+               <name>*dbprefix*table</name>
+
+               <declaration>
+                       <field>
+                               <name>auto_id</name>
+                               <type>integer</type>
+                               <default>0</default>
+                               <notnull>true</notnull>
+                               <autoincrement>1</autoincrement>
+                               <length>4</length>
+                       </field>
+                       <field>
+                               <name>textfield</name>
+                               <type>text</type>
+                               <default>foo</default>
+                               <notnull>true</notnull>
+                               <length>32</length>
+                       </field>
+               </declaration>
+       </table>
+</database>
diff --git a/tests/lib/db/ts-autoincrement-before.xml b/tests/lib/db/ts-autoincrement-before.xml
new file mode 100644 (file)
index 0000000..412739e
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<database>
+
+       <name>*dbname*</name>
+       <create>true</create>
+       <overwrite>false</overwrite>
+
+       <charset>utf8</charset>
+
+       <table>
+
+               <name>*dbprefix*table</name>
+
+               <declaration>
+                       <field>
+                               <name>textfield</name>
+                               <type>text</type>
+                               <default>foo</default>
+                               <notnull>true</notnull>
+                               <length>32</length>
+                       </field>
+               </declaration>
+       </table>
+</database>