diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-12-15 08:30:53 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-12-15 08:30:53 +0000 |
commit | 8b0fc579113af6be4357f881b2d12cd885af3d46 (patch) | |
tree | d71521372e49b1418e17298c24e0ecc599f4a9a4 /includes/database/mysql | |
parent | c3080a04019a7c15ad5bb47634be15aae97240d7 (diff) | |
download | brdo-8b0fc579113af6be4357f881b2d12cd885af3d46.tar.gz brdo-8b0fc579113af6be4357f881b2d12cd885af3d46.tar.bz2 |
- Patch #360854 by sammys, Crell: added missing db_index_exists(), required to provide proper upgrade path from Drupal 6 to Drupal 7.
Diffstat (limited to 'includes/database/mysql')
-rw-r--r-- | includes/database/mysql/schema.inc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc index 4fa20abf8..b87bb16d3 100644 --- a/includes/database/mysql/schema.inc +++ b/includes/database/mysql/schema.inc @@ -269,11 +269,11 @@ class DatabaseSchema_mysql extends DatabaseSchema { } public function renameTable($table, $new_name) { - $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO {' . $new_name . '}'); + $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO {' . $new_name . '}'); } public function dropTable($table) { - $this->connection->query('DROP TABLE {' . $table . '}'); + $this->connection->query('DROP TABLE {' . $table . '}'); } public function addField($table, $field, $spec, $keys_new = array()) { @@ -300,7 +300,7 @@ class DatabaseSchema_mysql extends DatabaseSchema { } public function dropField($table, $field) { - $this->connection->query('ALTER TABLE {' . $table . '} DROP `' . $field . '`'); + $this->connection->query('ALTER TABLE {' . $table . '} DROP `' . $field . '`'); } public function fieldSetDefault($table, $field, $default) { @@ -315,31 +315,35 @@ class DatabaseSchema_mysql extends DatabaseSchema { } public function fieldSetNoDefault($table, $field) { - $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT'); + $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT'); + } + + public function indexExists($table, $name) { + return $this->connection->query('SHOW INDEX FROM {' . $table . "} WHERE key_name = '$name'")->fetchField(); } public function addPrimaryKey($table, $fields) { - $this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')'); + $this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')'); } public function dropPrimaryKey($table) { - $this->connection->query('ALTER TABLE {' . $table . '} DROP PRIMARY KEY'); + $this->connection->query('ALTER TABLE {' . $table . '} DROP PRIMARY KEY'); } public function addUniqueKey($table, $name, $fields) { - $this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')'); + $this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')'); } public function dropUniqueKey($table, $name) { - $this->connection->query('ALTER TABLE {' . $table . '} DROP KEY `' . $name . '`'); + $this->connection->query('ALTER TABLE {' . $table . '} DROP KEY `' . $name . '`'); } public function addIndex($table, $name, $fields) { - $this->connection->query('ALTER TABLE {' . $table . '} ADD INDEX `' . $name . '` (' . $this->createKeySql($fields) . ')'); + $this->connection->query('ALTER TABLE {' . $table . '} ADD INDEX `' . $name . '` (' . $this->createKeySql($fields) . ')'); } public function dropIndex($table, $name) { - $this->connection->query('ALTER TABLE {' . $table . '} DROP INDEX `' . $name . '`'); + $this->connection->query('ALTER TABLE {' . $table . '} DROP INDEX `' . $name . '`'); } public function changeField($table, $field, $field_new, $spec, $keys_new = array()) { |