remove structureDump - it's entirely backend-specific and should be replaced
authorChuck Hagenbuch <chuck@horde.org>
Thu, 14 Jan 2010 21:00:37 +0000 (16:00 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Thu, 14 Jan 2010 21:28:50 +0000 (16:28 -0500)
with a migration generator of some sort (see TODO.txt).

framework/Db/lib/Horde/Db/Adapter/Base/Schema.php
framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php
framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php
framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php
framework/Db/test/Horde/Db/Adapter/MysqliTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php

index 690cc73..2957c6a 100644 (file)
@@ -628,15 +628,6 @@ abstract class Horde_Db_Adapter_Base_Schema
     }
 
     /**
-     * Returns a string of <tt>CREATE TABLE</tt> SQL statement(s) for recreating the
-     * entire structure of the database.
-     *
-     * @param   string  $table
-     * @return  string
-     */
-    abstract public function structureDump($table = null);
-
-    /**
      * Recreate the given db
      *
      * @param   string  $name
index 9b511bb..ddbf4dd 100644 (file)
@@ -88,22 +88,6 @@ class Horde_Db_Adapter_Mysql_Schema extends Horde_Db_Adapter_Base_Schema
     }
 
     /**
-     * Dump entire schema structure or specific table
-     *
-     * @param   string  $table
-     * @return  string
-     */
-    public function structureDump($table=null)
-    {
-        foreach ($this->selectAll('SHOW TABLES') as $row) {
-            if ($table && $table != current($row)) { continue; }
-            $dump = $this->selectOne('SHOW CREATE TABLE ' . $this->quoteTableName(current($row)));
-            $creates[] = $dump['Create Table'] . ';';
-        }
-        return isset($creates) ? implode("\n\n", $creates) : null;
-    }
-
-    /**
      * Create the given db
      *
      * @param   string  $name
index 083acde..c49f97d 100644 (file)
@@ -123,17 +123,6 @@ class Horde_Db_Adapter_Postgresql_Schema extends Horde_Db_Adapter_Base_Schema
     }
 
     /**
-     * Returns a string of <tt>CREATE TABLE</tt> SQL statement(s) for recreating the
-     * entire structure of the database.
-     *
-     * @param   string  $table
-     * @return  string
-     */
-    public function structureDump($table=null)
-    {
-    }
-
-    /**
      * Create a new PostgreSQL database.  Options include <tt>:owner</tt>, <tt>:template</tt>,
      * <tt>:encoding</tt>, <tt>:tablespace</tt>, and <tt>:connection_limit</tt> (note that MySQL uses
      * <tt>:charset</tt> while PostgreSQL uses <tt>:encoding</tt>).
index aad7343..6ff7efa 100644 (file)
@@ -64,26 +64,6 @@ class Horde_Db_Adapter_Sqlite_Schema extends Horde_Db_Adapter_Base_Schema
     }
 
     /**
-     * Dump entire schema structure or specific table
-     *
-     * @param   string  $table
-     * @return  string
-     */
-    public function structureDump($table=null)
-    {
-        if ($table) {
-            return $this->selectValue('SELECT sql FROM (
-                SELECT * FROM sqlite_master UNION ALL
-                SELECT * FROM sqlite_temp_master) WHERE type != \'meta\' AND name = ' . $this->quote($table));
-        } else {
-            $dump = $this->selectValues('SELECT sql FROM (
-                SELECT * FROM sqlite_master UNION ALL
-                SELECT * FROM sqlite_temp_master) WHERE type != \'meta\' AND name != \'sqlite_sequence\'');
-            return implode("\n\n", $dump);
-        }
-    }
-
-    /**
      * Create the given db
      *
      * @param   string  $name
index 0b6e17a..83cf492 100644 (file)
@@ -1027,38 +1027,6 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('test', $name);
     }
 
-    public function testStructureDump()
-    {
-        $this->_createTestTable('sports');
-        // Avoid AUTO_INCREMENT being a part of the dump
-        $this->_conn->execute('TRUNCATE TABLE sports');
-
-        // single table
-        $structure = $this->_conn->structureDump('sports');
-
-        $expected = "CREATE TABLE `sports` (\n".
-        "  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n".
-        "  `name` varchar(255) DEFAULT NULL,\n".
-        "  `is_college` tinyint(1) DEFAULT NULL,\n".
-        "  PRIMARY KEY (`id`)\n".
-        ") ENGINE=InnoDB DEFAULT CHARSET=utf8";
-
-        // MySQL differs in how it dumps table structure between versions, so do
-        // some normalization.
-        $expected = strtolower(preg_replace('/\s+/', ' ', $expected));
-        $structure = strtolower(preg_replace('/\s+/', ' ', $structure));
-
-        $this->assertContains($expected, $structure);
-
-        // entire structure
-        $structure = $this->_conn->structureDump();
-        $structure = strtolower(preg_replace('/\s+/', ' ', $structure));
-
-        // contains, but doesn't match only sports table
-        $this->assertContains($expected, $structure);
-        $this->assertNotEquals($expected, $structure);
-    }
-
     public function testTypeToSqlTypePrimaryKey()
     {
         $result = $this->_conn->typeToSql('primaryKey');
index cb787cd..0cf9eee 100644 (file)
@@ -1047,38 +1047,6 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('test', $name);
     }
 
-    public function testStructureDump()
-    {
-        $this->_createTestTable('sports');
-        // Avoid AUTO_INCREMENT being a part of the dump
-        $this->_conn->execute('TRUNCATE TABLE sports');
-
-        // single table
-        $structure = $this->_conn->structureDump('sports');
-
-        $expected = "CREATE TABLE `sports` (\n".
-        "  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n".
-        "  `name` varchar(255) DEFAULT NULL,\n".
-        "  `is_college` tinyint(1) DEFAULT NULL,\n".
-        "  PRIMARY KEY (`id`)\n".
-        ") ENGINE=InnoDB DEFAULT CHARSET=utf8";
-
-        // MySQL differs in how it dumps table structure between versions, so do
-        // some normalization.
-        $expected = strtolower(preg_replace('/\s+/', ' ', $expected));
-        $structure = strtolower(preg_replace('/\s+/', ' ', $structure));
-
-        $this->assertContains($expected, $structure);
-
-        // entire structure
-        $structure = $this->_conn->structureDump();
-        $structure = strtolower(preg_replace('/\s+/', ' ', $structure));
-
-        // contains, but doesn't match only sports table
-        $this->assertContains($expected, $structure);
-        $this->assertNotEquals($expected, $structure);
-    }
-
     public function testTypeToSqlTypePrimaryKey()
     {
         $result = $this->_conn->typeToSql('primaryKey');
index d597bad..b0b3f27 100644 (file)
@@ -923,29 +923,6 @@ class Horde_Db_Adapter_Pdo_SqliteTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('test', $name);
     }
 
-    public function testStructureDump()
-    {
-        $this->_createTestTable('sports');
-
-        // single table
-        $structure = $this->_conn->structureDump('sports');
-
-        $expected = "CREATE TABLE \"sports\" (\n".
-        "  \"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \n".
-        "  \"name\" varchar(255), \n".
-        "  \"is_college\" boolean\n".
-        ")";
-
-        $this->assertContains($expected, $structure);
-
-        // entire structure
-        $structure = $this->_conn->structureDump();
-
-        // contains, but doesn't match only sports table
-        $this->assertContains($expected, $structure);
-        $this->assertNotEquals($expected, $structure);
-    }
-
     public function testTypeToSqlTypePrimaryKey()
     {
         $result = $this->_conn->typeToSql('primaryKey');