From aa98cec29ae9eea639d828f1261e086f42d21a99 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Thu, 14 Jan 2010 16:00:37 -0500 Subject: [PATCH] remove structureDump - it's entirely backend-specific and should be replaced with a migration generator of some sort (see TODO.txt). --- framework/Db/lib/Horde/Db/Adapter/Base/Schema.php | 9 ------ framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php | 16 ----------- .../Db/lib/Horde/Db/Adapter/Postgresql/Schema.php | 11 -------- .../Db/lib/Horde/Db/Adapter/Sqlite/Schema.php | 20 -------------- framework/Db/test/Horde/Db/Adapter/MysqliTest.php | 32 ---------------------- .../Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php | 32 ---------------------- .../Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php | 23 ---------------- 7 files changed, 143 deletions(-) diff --git a/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php index 690cc736c..2957c6ab6 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php +++ b/framework/Db/lib/Horde/Db/Adapter/Base/Schema.php @@ -628,15 +628,6 @@ abstract class Horde_Db_Adapter_Base_Schema } /** - * Returns a string of CREATE TABLE 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 diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php index 9b511bb50..ddbf4dd5f 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php @@ -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 diff --git a/framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php index 083acdebe..c49f97d05 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php +++ b/framework/Db/lib/Horde/Db/Adapter/Postgresql/Schema.php @@ -123,17 +123,6 @@ class Horde_Db_Adapter_Postgresql_Schema extends Horde_Db_Adapter_Base_Schema } /** - * Returns a string of CREATE TABLE 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 :owner, :template, * :encoding, :tablespace, and :connection_limit (note that MySQL uses * :charset while PostgreSQL uses :encoding). diff --git a/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php index aad73434b..6ff7efa95 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php +++ b/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php @@ -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 diff --git a/framework/Db/test/Horde/Db/Adapter/MysqliTest.php b/framework/Db/test/Horde/Db/Adapter/MysqliTest.php index 0b6e17a6d..83cf4928e 100644 --- a/framework/Db/test/Horde/Db/Adapter/MysqliTest.php +++ b/framework/Db/test/Horde/Db/Adapter/MysqliTest.php @@ -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'); diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php index cb787cd0e..0cf9eee32 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php @@ -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'); diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php index d597bad06..b0b3f2790 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php @@ -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'); -- 2.11.0